File: Internal.hs

package info (click to toggle)
haskell-text-icu 0.8.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 536 kB
  • sloc: haskell: 1,210; ansic: 1,147; makefile: 4
file content (51 lines) | stat: -rw-r--r-- 1,566 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{-# LANGUAGE DeriveDataTypeable, EmptyDataDecls, ForeignFunctionInterface #-}
-- |
-- Module      : Data.Text.ICU.Collate.Internal
-- Copyright   : (c) 2010 Bryan O'Sullivan
--
-- License     : BSD-style
-- Maintainer  : bos@serpentine.com
-- Stability   : experimental
-- Portability : GHC
--
-- Internals of the string collation infrastructure.

module Data.Text.ICU.Number.Internal
    (
    -- * Unicode collation API
      MNumberFormat(..)
    , NumberFormat(..)
    , UNumberFormat
    , withNumberFormat
    , wrap
    )
where

import Data.Typeable (Typeable)
import Foreign.ForeignPtr (ForeignPtr, withForeignPtr)
import Foreign.Ptr (FunPtr, Ptr)
import Data.Text.ICU.Internal (newICUPtr)

-- $api
--

data UNumberFormat

-- | This is the number formatter. It can be created with 'formatter'. Use it to format numbers with the 'format' function.
data MNumberFormat = MNumberFormat {-# UNPACK #-} !(ForeignPtr UNumberFormat)
                 deriving (Typeable)

-- | This is the number formatter. It can be created with 'formatter'. Use it to format numbers with the 'format' function.
newtype NumberFormat = C MNumberFormat
    deriving (Typeable)

withNumberFormat :: MNumberFormat -> (Ptr UNumberFormat -> IO a) -> IO a
withNumberFormat (MNumberFormat col) action = withForeignPtr col action
{-# INLINE withNumberFormat #-}

wrap :: IO (Ptr UNumberFormat) -> IO MNumberFormat
wrap = newICUPtr MNumberFormat unum_close
{-# INLINE wrap #-}

foreign import ccall unsafe "hs_text_icu.h &__hs_unum_close" unum_close
    :: FunPtr (Ptr UNumberFormat -> IO ())