- type IOS s t = STLike IO s t
- io :: IO t -> IOS s t
- runIOS :: (forall s. IOS s t) -> IO t
- data Regioned s t
- runRegion :: (NotShared ty, RegionMonad m region s) => Regioned s ty -> STLike m region ty
- region :: t -> Regioned s t
- unfoldRegion :: Foldable t => Regioned s (t a) -> [Regioned s a]
- class STLikeImpl m => RegionMonad m region s
- data a :< b
- withRIOR :: IOS o resource -> (resource -> IOS o ()) -> (forall s. Regioned (s :< o) resource -> IOS (s :< o) result) -> IOS o result
- try :: IOS s t -> IOS s (Either SomeException t)
- rbsFromPtr :: Ptr a -> Int -> IOS s (Regioned s ByteString)
- rbsToBS :: RegionMonad m s reg => Regioned s ByteString -> STLike m reg ByteString
- withRbsPtr :: Regioned s ByteString -> (Ptr any -> Int -> IOS s t) -> IOS s t
- rbsMapLookup :: (RegionMonad m s reg, Ord key) => Regioned s key -> Map key value -> STLike m reg (Maybe value)
IOS monad
type IOS s t = STLike IO s tSource
Monad for scoped IO computations The underlying monad must be strict here.
Regioned monad
Regioned variables. A regioned variable is safe i.e. no references to it may escape the current IOS.
runRegion :: (NotShared ty, RegionMonad m region s) => Regioned s ty -> STLike m region tySource
Run a computation on regioned data and return the result in a strict fashion.
unfoldRegion :: Foldable t => Regioned s (t a) -> [Regioned s a]Source
Utilities
class STLikeImpl m => RegionMonad m region s Source
(STLikeImpl m, TypeCast reg (:< any rest), RegionMonad m rest s) => RegionMonad m reg s | |
STLikeImpl m => RegionMonad m s s |
:: IOS o resource | Open the resource |
-> (resource -> IOS o ()) | Close it. |
-> (forall s. Regioned (s :< o) resource -> IOS (s :< o) result) | Compute with it. |
-> IOS o result |
Use a resource with IOS. Like bracket.
rbsFromPtr :: Ptr a -> Int -> IOS s (Regioned s ByteString)Source
Create a ByteString representing the pointer and length. No copying done, O(1).
rbsToBS :: RegionMonad m s reg => Regioned s ByteString -> STLike m reg ByteStringSource
Create a copy of a regioned ByteString as a normal ByteString. O(n).
withRbsPtr :: Regioned s ByteString -> (Ptr any -> Int -> IOS s t) -> IOS s tSource
Use a regioned ByteString as a pointer. O(1). The pointer points to the region contents, so be cafeful with it.
rbsMapLookup :: (RegionMonad m s reg, Ord key) => Regioned s key -> Map key value -> STLike m reg (Maybe value)Source
Lookup inside a Map with a regioned ByteString.