module Basement.Runtime
where
import Basement.Compat.Base
import Basement.Types.OffsetSize
import System.Environment
import System.IO.Unsafe (unsafePerformIO)
import Text.Read (readMaybe)
unsafeUArrayUnpinnedMaxSize :: CountOf Word8
unsafeUArrayUnpinnedMaxSize :: CountOf Word8
unsafeUArrayUnpinnedMaxSize = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ do
Maybe Int
maxSize <- (forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall a. Read a => String -> Maybe a
readMaybe) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> IO (Maybe String)
lookupEnv String
"HS_FOUNDATION_UARRAY_UNPINNED_MAX"
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall b a. b -> (a -> b) -> Maybe a -> b
maybe (forall ty. Int -> CountOf ty
CountOf Int
1024) forall ty. Int -> CountOf ty
CountOf Maybe Int
maxSize
{-# NOINLINE unsafeUArrayUnpinnedMaxSize #-}