{-# LANGUAGE DeriveDataTypeable, EmptyDataDecls, ForeignFunctionInterface #-}
module Data.Text.ICU.Collate.Internal
(
MCollator(..)
, Collator(..)
, UCollator
, withCollator
, wrap
) where
import Data.Typeable (Typeable)
import Foreign.ForeignPtr (ForeignPtr, newForeignPtr, withForeignPtr)
import Foreign.Ptr (FunPtr, Ptr)
data UCollator
data MCollator = MCollator {-# UNPACK #-} !(ForeignPtr UCollator)
deriving (Typeable)
newtype Collator = C MCollator
deriving (Typeable)
withCollator :: MCollator -> (Ptr UCollator -> IO a) -> IO a
withCollator :: MCollator -> (Ptr UCollator -> IO a) -> IO a
withCollator (MCollator ForeignPtr UCollator
col) Ptr UCollator -> IO a
action = ForeignPtr UCollator -> (Ptr UCollator -> IO a) -> IO a
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr UCollator
col Ptr UCollator -> IO a
action
{-# INLINE withCollator #-}
wrap :: Ptr UCollator -> IO MCollator
wrap :: Ptr UCollator -> IO MCollator
wrap = (ForeignPtr UCollator -> MCollator)
-> IO (ForeignPtr UCollator) -> IO MCollator
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ForeignPtr UCollator -> MCollator
MCollator (IO (ForeignPtr UCollator) -> IO MCollator)
-> (Ptr UCollator -> IO (ForeignPtr UCollator))
-> Ptr UCollator
-> IO MCollator
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FinalizerPtr UCollator
-> Ptr UCollator -> IO (ForeignPtr UCollator)
forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
newForeignPtr FinalizerPtr UCollator
ucol_close
{-# INLINE wrap #-}
foreign import ccall unsafe "hs_text_icu.h &__hs_ucol_close" ucol_close
:: FunPtr (Ptr UCollator -> IO ())