{-# LINE 1 "Data/Text/ICU/Internal.hsc" #-}
{-# LANGUAGE EmptyDataDecls, ForeignFunctionInterface, GeneralizedNewtypeDeriving, TupleSections #-}
module Data.Text.ICU.Internal
(
LocaleName(..)
, UBool
, UChar
, UChar32
, UCharIterator
, CharIterator(..)
, UText, UTextPtr
, asBool
, asOrdering
, withCharIterator
, withLocaleName
, withName
, useAsUCharPtr, fromUCharPtr, I16, asUCharForeignPtr
, asUTextPtr, withUTextPtr, withUTextPtrText, emptyUTextPtr, utextPtrLength
, TextI, takeWord, dropWord, lengthWord
, newICUPtr
) where
import Control.Exception (mask_)
import Control.DeepSeq (NFData(..))
import Data.ByteString.Internal (ByteString(..))
import Data.Int (Int8, Int32, Int64)
import Data.String (IsString(..))
import Data.Text (Text, empty)
import Data.Text.Encoding (decodeUtf8)
import Data.Text.Foreign (useAsPtr, asForeignPtr, fromPtr)
{-# LINE 34 "Data/Text/ICU/Internal.hsc" #-}
import Data.Text.Foreign (I8, dropWord8, takeWord8, lengthWord8)
import Foreign.ForeignPtr (mallocForeignPtrArray)
import Foreign.Marshal.Array (allocaArray)
import Foreign.Storable (peek)
{-# LINE 41 "Data/Text/ICU/Internal.hsc" #-}
import Data.Word (Word8, Word16, Word32)
import Foreign.C.String (CString, withCString)
import Foreign.ForeignPtr (withForeignPtr, ForeignPtr, newForeignPtr, FinalizerPtr)
import Foreign.Marshal.Alloc (allocaBytes)
import Foreign.Marshal.Utils (with)
import Foreign.Ptr (Ptr, nullPtr, FunPtr)
import Data.Text.ICU.Error.Internal (UErrorCode)
import System.IO.Unsafe (unsafePerformIO)
data CharIterator = CIText !Text
| CIUTF8 !ByteString
instance Show CharIterator where
show :: CharIterator -> String
show (CIText Text
t) = Text -> String
forall a. Show a => a -> String
show Text
t
show (CIUTF8 ByteString
bs) = Text -> String
forall a. Show a => a -> String
show (ByteString -> Text
decodeUtf8 ByteString
bs)
data UCharIterator
withCharIterator :: CharIterator -> (Ptr UCharIterator -> IO a) -> IO a
withCharIterator :: forall a. CharIterator -> (Ptr UCharIterator -> IO a) -> IO a
withCharIterator (CIUTF8 (PS ForeignPtr Word8
fp Int
_ Int
l)) Ptr UCharIterator -> IO a
act =
Int -> (Ptr UCharIterator -> IO a) -> IO a
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes ((Int
112)) ((Ptr UCharIterator -> IO a) -> IO a)
-> (Ptr UCharIterator -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \Ptr UCharIterator
i -> ForeignPtr Word8 -> (Ptr Word8 -> IO a) -> IO a
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Word8
fp ((Ptr Word8 -> IO a) -> IO a) -> (Ptr Word8 -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
p ->
{-# LINE 71 "Data/Text/ICU/Internal.hsc" #-}
uiter_setUTF8 i p (fromIntegral l) >> act i
withCharIterator (CIText Text
t) Ptr UCharIterator -> IO a
act =
Int -> (Ptr UCharIterator -> IO a) -> IO a
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes ((Int
112)) ((Ptr UCharIterator -> IO a) -> IO a)
-> (Ptr UCharIterator -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \Ptr UCharIterator
i -> Text -> (Ptr Word8 -> I8 -> IO a) -> IO a
forall a. Text -> (Ptr Word8 -> I8 -> IO a) -> IO a
useAsPtr Text
t ((Ptr Word8 -> I8 -> IO a) -> IO a)
-> (Ptr Word8 -> I8 -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
p I8
l ->
{-# LINE 74 "Data/Text/ICU/Internal.hsc" #-}
{-# LINE 75 "Data/Text/ICU/Internal.hsc" #-}
uiter_setUTF8 i p (fromIntegral l) >> act i
{-# LINE 79 "Data/Text/ICU/Internal.hsc" #-}
type UBool = Int8
type UChar = Word16
type UChar32 = Word32
asBool :: Integral a => a -> Bool
{-# INLINE asBool #-}
asBool :: forall a. Integral a => a -> Bool
asBool = (a -> a -> Bool
forall a. Eq a => a -> a -> Bool
/=a
0)
asOrdering :: Integral a => a -> Ordering
{-# INLINE asOrdering #-}
asOrdering :: forall a. Integral a => a -> Ordering
asOrdering a
i
| a
i a -> a -> Bool
forall a. Ord a => a -> a -> Bool
< a
0 = Ordering
LT
| a
i a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
0 = Ordering
EQ
| Bool
otherwise = Ordering
GT
withName :: String -> (CString -> IO a) -> IO a
withName :: forall a. String -> (CString -> IO a) -> IO a
withName String
name CString -> IO a
act
| String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
name = CString -> IO a
act CString
forall a. Ptr a
nullPtr
| Bool
otherwise = String -> (CString -> IO a) -> IO a
forall a. String -> (CString -> IO a) -> IO a
withCString String
name CString -> IO a
act
data LocaleName = Root
| Locale String
| Current
deriving (LocaleName -> LocaleName -> Bool
(LocaleName -> LocaleName -> Bool)
-> (LocaleName -> LocaleName -> Bool) -> Eq LocaleName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LocaleName -> LocaleName -> Bool
$c/= :: LocaleName -> LocaleName -> Bool
== :: LocaleName -> LocaleName -> Bool
$c== :: LocaleName -> LocaleName -> Bool
Eq, Eq LocaleName
Eq LocaleName
-> (LocaleName -> LocaleName -> Ordering)
-> (LocaleName -> LocaleName -> Bool)
-> (LocaleName -> LocaleName -> Bool)
-> (LocaleName -> LocaleName -> Bool)
-> (LocaleName -> LocaleName -> Bool)
-> (LocaleName -> LocaleName -> LocaleName)
-> (LocaleName -> LocaleName -> LocaleName)
-> Ord LocaleName
LocaleName -> LocaleName -> Bool
LocaleName -> LocaleName -> Ordering
LocaleName -> LocaleName -> LocaleName
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: LocaleName -> LocaleName -> LocaleName
$cmin :: LocaleName -> LocaleName -> LocaleName
max :: LocaleName -> LocaleName -> LocaleName
$cmax :: LocaleName -> LocaleName -> LocaleName
>= :: LocaleName -> LocaleName -> Bool
$c>= :: LocaleName -> LocaleName -> Bool
> :: LocaleName -> LocaleName -> Bool
$c> :: LocaleName -> LocaleName -> Bool
<= :: LocaleName -> LocaleName -> Bool
$c<= :: LocaleName -> LocaleName -> Bool
< :: LocaleName -> LocaleName -> Bool
$c< :: LocaleName -> LocaleName -> Bool
compare :: LocaleName -> LocaleName -> Ordering
$ccompare :: LocaleName -> LocaleName -> Ordering
Ord, ReadPrec [LocaleName]
ReadPrec LocaleName
Int -> ReadS LocaleName
ReadS [LocaleName]
(Int -> ReadS LocaleName)
-> ReadS [LocaleName]
-> ReadPrec LocaleName
-> ReadPrec [LocaleName]
-> Read LocaleName
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LocaleName]
$creadListPrec :: ReadPrec [LocaleName]
readPrec :: ReadPrec LocaleName
$creadPrec :: ReadPrec LocaleName
readList :: ReadS [LocaleName]
$creadList :: ReadS [LocaleName]
readsPrec :: Int -> ReadS LocaleName
$creadsPrec :: Int -> ReadS LocaleName
Read, Int -> LocaleName -> ShowS
[LocaleName] -> ShowS
LocaleName -> String
(Int -> LocaleName -> ShowS)
-> (LocaleName -> String)
-> ([LocaleName] -> ShowS)
-> Show LocaleName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LocaleName] -> ShowS
$cshowList :: [LocaleName] -> ShowS
show :: LocaleName -> String
$cshow :: LocaleName -> String
showsPrec :: Int -> LocaleName -> ShowS
$cshowsPrec :: Int -> LocaleName -> ShowS
Show)
instance NFData LocaleName where
rnf :: LocaleName -> ()
rnf LocaleName
Root = ()
rnf (Locale String
l) = String -> ()
forall a. NFData a => a -> ()
rnf String
l
rnf LocaleName
Current = ()
instance IsString LocaleName where
fromString :: String -> LocaleName
fromString = String -> LocaleName
Locale
withLocaleName :: LocaleName -> (CString -> IO a) -> IO a
withLocaleName :: forall a. LocaleName -> (CString -> IO a) -> IO a
withLocaleName LocaleName
Current CString -> IO a
act = CString -> IO a
act CString
forall a. Ptr a
nullPtr
withLocaleName LocaleName
Root CString -> IO a
act = String -> (CString -> IO a) -> IO a
forall a. String -> (CString -> IO a) -> IO a
withCString String
"" CString -> IO a
act
withLocaleName (Locale String
n) CString -> IO a
act = String -> (CString -> IO a) -> IO a
forall a. String -> (CString -> IO a) -> IO a
withCString String
n CString -> IO a
act
{-# LINE 126 "Data/Text/ICU/Internal.hsc" #-}
foreign import ccall unsafe "hs_text_icu.h __hs_uiter_setUTF8" uiter_setUTF8
:: Ptr UCharIterator -> Ptr Word8 -> Int32 -> IO ()
data UText
data UTextPtr
= UTextPtr
{ UTextPtr -> ForeignPtr UText
utextPtr :: ForeignPtr UText
, UTextPtr -> ForeignPtr Word8
utextPtrText :: ForeignPtr TextChar
, UTextPtr -> I8
utextPtrLength :: TextI
}
emptyUTextPtr :: UTextPtr
emptyUTextPtr :: UTextPtr
emptyUTextPtr = IO UTextPtr -> UTextPtr
forall a. IO a -> a
unsafePerformIO (IO UTextPtr -> UTextPtr) -> IO UTextPtr -> UTextPtr
forall a b. (a -> b) -> a -> b
$ Text -> IO UTextPtr
asUTextPtr Text
empty
{-# NOINLINE emptyUTextPtr #-}
withUTextPtr :: UTextPtr -> (Ptr UText -> IO a) -> IO a
withUTextPtr :: forall a. UTextPtr -> (Ptr UText -> IO a) -> IO a
withUTextPtr = ForeignPtr UText -> (Ptr UText -> IO a) -> IO a
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr (ForeignPtr UText -> (Ptr UText -> IO a) -> IO a)
-> (UTextPtr -> ForeignPtr UText)
-> UTextPtr
-> (Ptr UText -> IO a)
-> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UTextPtr -> ForeignPtr UText
utextPtr
withUTextPtrText :: UTextPtr -> (Ptr TextChar -> IO a) -> IO a
withUTextPtrText :: forall a. UTextPtr -> (Ptr Word8 -> IO a) -> IO a
withUTextPtrText = ForeignPtr Word8 -> (Ptr Word8 -> IO a) -> IO a
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr (ForeignPtr Word8 -> (Ptr Word8 -> IO a) -> IO a)
-> (UTextPtr -> ForeignPtr Word8)
-> UTextPtr
-> (Ptr Word8 -> IO a)
-> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UTextPtr -> ForeignPtr Word8
utextPtrText
asUTextPtr :: Text -> IO UTextPtr
asUTextPtr :: Text -> IO UTextPtr
asUTextPtr Text
t = do
(ForeignPtr Word8
fp,I8
l) <- Text -> IO (ForeignPtr Word8, I8)
asForeignPtr Text
t
UErrorCode -> (Ptr UErrorCode -> IO UTextPtr) -> IO UTextPtr
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with UErrorCode
0 ((Ptr UErrorCode -> IO UTextPtr) -> IO UTextPtr)
-> (Ptr UErrorCode -> IO UTextPtr) -> IO UTextPtr
forall a b. (a -> b) -> a -> b
$ \ Ptr UErrorCode
e -> ForeignPtr Word8 -> (Ptr Word8 -> IO UTextPtr) -> IO UTextPtr
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Word8
fp ((Ptr Word8 -> IO UTextPtr) -> IO UTextPtr)
-> (Ptr Word8 -> IO UTextPtr) -> IO UTextPtr
forall a b. (a -> b) -> a -> b
$ \ Ptr Word8
p ->
(ForeignPtr UText -> UTextPtr)
-> FinalizerPtr UText -> IO (Ptr UText) -> IO UTextPtr
forall a i.
(ForeignPtr a -> i) -> FinalizerPtr a -> IO (Ptr a) -> IO i
newICUPtr (\ ForeignPtr UText
ut -> ForeignPtr UText -> ForeignPtr Word8 -> I8 -> UTextPtr
UTextPtr ForeignPtr UText
ut ForeignPtr Word8
fp I8
l) FinalizerPtr UText
utext_close (IO (Ptr UText) -> IO UTextPtr) -> IO (Ptr UText) -> IO UTextPtr
forall a b. (a -> b) -> a -> b
$
{-# LINE 159 "Data/Text/ICU/Internal.hsc" #-}
Ptr UText -> Ptr Word8 -> Int64 -> Ptr UErrorCode -> IO (Ptr UText)
utext_openUTF8
{-# LINE 163 "Data/Text/ICU/Internal.hsc" #-}
Ptr UText
forall a. Ptr a
nullPtr Ptr Word8
p (I8 -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral I8
l) Ptr UErrorCode
e
foreign import ccall unsafe "hs_text_icu.h &__hs_utext_close" utext_close
:: FunPtr (Ptr UText -> IO ())
useAsUCharPtr :: Text -> (Ptr UChar -> I16 -> IO a) -> IO a
asUCharForeignPtr :: Text -> IO (ForeignPtr UChar, I16)
fromUCharPtr :: Ptr UChar -> I16 -> IO Text
dropWord, takeWord :: TextI -> Text -> Text
lengthWord :: Text -> Int
{-# LINE 176 "Data/Text/ICU/Internal.hsc" #-}
newtype I16 = I16 Int
deriving (Bounded, Enum, Eq, Integral, Num, Ord, Read, Real, Show)
type TextChar = Word8
type TextI = I8
useAsUCharPtr :: forall a. Text -> (Ptr UChar -> I16 -> IO a) -> IO a
useAsUCharPtr Text
t Ptr UChar -> I16 -> IO a
act = Text -> (Ptr Word8 -> I8 -> IO a) -> IO a
forall a. Text -> (Ptr Word8 -> I8 -> IO a) -> IO a
useAsPtr Text
t ((Ptr Word8 -> I8 -> IO a) -> IO a)
-> (Ptr Word8 -> I8 -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
tptr I8
tlen ->
Int -> (Ptr UChar -> IO a) -> IO a
forall a b. Storable a => Int -> (Ptr a -> IO b) -> IO b
allocaArray (I8 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral I8
tlen) ((Ptr UChar -> IO a) -> IO a) -> (Ptr UChar -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \ Ptr UChar
dst ->
Ptr UChar -> I16 -> IO a
act Ptr UChar
dst (I16 -> IO a) -> IO I16 -> IO a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr UChar -> Ptr Word8 -> I8 -> IO I16
fromUtf8 Ptr UChar
dst Ptr Word8
tptr I8
tlen
asUCharForeignPtr :: Text -> IO (ForeignPtr UChar, I16)
asUCharForeignPtr Text
t = Text
-> (Ptr Word8 -> I8 -> IO (ForeignPtr UChar, I16))
-> IO (ForeignPtr UChar, I16)
forall a. Text -> (Ptr Word8 -> I8 -> IO a) -> IO a
useAsPtr Text
t ((Ptr Word8 -> I8 -> IO (ForeignPtr UChar, I16))
-> IO (ForeignPtr UChar, I16))
-> (Ptr Word8 -> I8 -> IO (ForeignPtr UChar, I16))
-> IO (ForeignPtr UChar, I16)
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
tptr I8
tlen -> do
ForeignPtr UChar
fp <- Int -> IO (ForeignPtr UChar)
forall a. Storable a => Int -> IO (ForeignPtr a)
mallocForeignPtrArray (I8 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral I8
tlen)
ForeignPtr UChar
-> (Ptr UChar -> IO (ForeignPtr UChar, I16))
-> IO (ForeignPtr UChar, I16)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr UChar
fp ((Ptr UChar -> IO (ForeignPtr UChar, I16))
-> IO (ForeignPtr UChar, I16))
-> (Ptr UChar -> IO (ForeignPtr UChar, I16))
-> IO (ForeignPtr UChar, I16)
forall a b. (a -> b) -> a -> b
$ \ Ptr UChar
dst -> (ForeignPtr UChar
fp,) (I16 -> (ForeignPtr UChar, I16))
-> IO I16 -> IO (ForeignPtr UChar, I16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr UChar -> Ptr Word8 -> I8 -> IO I16
fromUtf8 Ptr UChar
dst Ptr Word8
tptr I8
tlen
fromUtf8 :: Ptr UChar -> Ptr Word8 -> I8 -> IO I16
fromUtf8 :: Ptr UChar -> Ptr Word8 -> I8 -> IO I16
fromUtf8 Ptr UChar
dst Ptr Word8
tptr I8
tlen =
UErrorCode -> (Ptr UErrorCode -> IO I16) -> IO I16
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with UErrorCode
0 ((Ptr UErrorCode -> IO I16) -> IO I16)
-> (Ptr UErrorCode -> IO I16) -> IO I16
forall a b. (a -> b) -> a -> b
$ \ Ptr UErrorCode
err ->
Int32 -> (Ptr Int32 -> IO I16) -> IO I16
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Int32
0 ((Ptr Int32 -> IO I16) -> IO I16)
-> (Ptr Int32 -> IO I16) -> IO I16
forall a b. (a -> b) -> a -> b
$ \ Ptr Int32
dstLen -> do
CString
_ <- Ptr UChar
-> Int32
-> Ptr Int32
-> Ptr Word8
-> Int32
-> Ptr UErrorCode
-> IO CString
u_strFromUTF8Lenient Ptr UChar
dst (I8 -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral I8
tlen) Ptr Int32
dstLen Ptr Word8
tptr
(I8 -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral I8
tlen) Ptr UErrorCode
err
Int32 -> I16
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int32 -> I16) -> IO Int32 -> IO I16
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
dstLen
fromUCharPtr :: Ptr UChar -> I16 -> IO Text
fromUCharPtr Ptr UChar
p I16
l =
UErrorCode -> (Ptr UErrorCode -> IO Text) -> IO Text
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with UErrorCode
0 ((Ptr UErrorCode -> IO Text) -> IO Text)
-> (Ptr UErrorCode -> IO Text) -> IO Text
forall a b. (a -> b) -> a -> b
$ \ Ptr UErrorCode
err ->
Int32 -> (Ptr Int32 -> IO Text) -> IO Text
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Int32
0 ((Ptr Int32 -> IO Text) -> IO Text)
-> (Ptr Int32 -> IO Text) -> IO Text
forall a b. (a -> b) -> a -> b
$ \ Ptr Int32
dstLen ->
Int -> (Ptr Word8 -> IO Text) -> IO Text
forall a b. Storable a => Int -> (Ptr a -> IO b) -> IO b
allocaArray Int
capacity ((Ptr Word8 -> IO Text) -> IO Text)
-> (Ptr Word8 -> IO Text) -> IO Text
forall a b. (a -> b) -> a -> b
$ \ Ptr Word8
dst -> do
CString
_ <- Ptr Word8
-> Int32
-> Ptr Int32
-> Ptr UChar
-> Int32
-> Ptr UErrorCode
-> IO CString
u_strToUTF8 Ptr Word8
dst (Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
capacity) Ptr Int32
dstLen Ptr UChar
p
(I16 -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral I16
l) Ptr UErrorCode
err
Int32
dl <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
dstLen
Ptr Word8 -> I8 -> IO Text
fromPtr Ptr Word8
dst (Int32 -> I8
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
dl)
where capacity :: Int
capacity = I16 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral I16
l Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
3
dropWord :: I8 -> Text -> Text
dropWord = I8 -> Text -> Text
dropWord8
takeWord :: I8 -> Text -> Text
takeWord = I8 -> Text -> Text
takeWord8
lengthWord :: Text -> Int
lengthWord = Text -> Int
lengthWord8
foreign import ccall unsafe "hs_text_icu.h __hs_u_strFromUTF8Lenient" u_strFromUTF8Lenient
:: Ptr UChar -> Int32 -> Ptr Int32 -> Ptr Word8 -> Int32 -> Ptr UErrorCode
-> IO CString
foreign import ccall unsafe "hs_text_icu.h __hs_u_strToUTF8" u_strToUTF8
:: Ptr Word8 -> Int32 -> Ptr Int32 -> Ptr UChar -> Int32 -> Ptr UErrorCode
-> IO CString
foreign import ccall unsafe "hs_text_icu.h __hs_utext_openUTF8" utext_openUTF8
:: Ptr UText -> Ptr Word8 -> Int64 -> Ptr UErrorCode -> IO (Ptr UText)
{-# LINE 241 "Data/Text/ICU/Internal.hsc" #-}
newICUPtr :: (ForeignPtr a -> i) -> FinalizerPtr a -> IO (Ptr a) -> IO i
newICUPtr :: forall a i.
(ForeignPtr a -> i) -> FinalizerPtr a -> IO (Ptr a) -> IO i
newICUPtr ForeignPtr a -> i
wrap FinalizerPtr a
close IO (Ptr a)
open = (ForeignPtr a -> i) -> IO (ForeignPtr a) -> IO i
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ForeignPtr a -> i
wrap (IO (ForeignPtr a) -> IO i) -> IO (ForeignPtr a) -> IO i
forall a b. (a -> b) -> a -> b
$ IO (ForeignPtr a) -> IO (ForeignPtr a)
forall a. IO a -> IO a
mask_ (IO (ForeignPtr a) -> IO (ForeignPtr a))
-> IO (ForeignPtr a) -> IO (ForeignPtr a)
forall a b. (a -> b) -> a -> b
$ FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
newForeignPtr FinalizerPtr a
close (Ptr a -> IO (ForeignPtr a)) -> IO (Ptr a) -> IO (ForeignPtr a)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO (Ptr a)
open