{-# LINE 1 "Data/Text/ICU/Locale.hsc" #-}
{-# LANGUAGE RankNTypes, BangPatterns, ForeignFunctionInterface, RecordWildCards #-}
module Data.Text.ICU.Locale
(availableLocales
) where
import Control.Monad (forM)
import Data.Int (Int32)
import Foreign.C.String (CString, peekCString)
import Prelude hiding (last)
availableLocales :: IO [String]
availableLocales :: IO [String]
availableLocales = do
Int32
n <- IO Int32
uloc_countAvailable
[Int32] -> (Int32 -> IO String) -> IO [String]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [Int32
0..Int32
nInt32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
-Int32
1] ((Int32 -> IO String) -> IO [String])
-> (Int32 -> IO String) -> IO [String]
forall a b. (a -> b) -> a -> b
$ \Int32
i -> Int32 -> IO CString
uloc_getAvailable Int32
i IO CString -> (CString -> IO String) -> IO String
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= CString -> IO String
peekCString
foreign import ccall unsafe "hs_text_icu.h __hs_uloc_getAvailable" uloc_getAvailable
:: Int32 -> IO CString
foreign import ccall unsafe "hs_text_icu.h __hs_uloc_countAvailable" uloc_countAvailable
:: IO Int32