llvm-extra-0.12.0.1: Utility functions for the llvm interface
Safe HaskellSafe-Inferred
LanguageHaskell98

LLVM.Extra.MaybeContinuation

Description

Maybe transformer datatype implemented in continuation passing style.

Synopsis

Documentation

newtype T r z a Source #

Isomorphic to ReaderT (CodeGenFunction r z) (ContT z (CodeGenFunction r)) a, where the reader provides the block for Nothing and the continuation part manages the Just.

Constructors

Cons 

Fields

Instances

Instances details
MonadIO (T r z) Source # 
Instance details

Defined in LLVM.Extra.MaybeContinuation

Methods

liftIO :: IO a -> T r z a #

Applicative (T r z) Source # 
Instance details

Defined in LLVM.Extra.MaybeContinuation

Methods

pure :: a -> T r z a #

(<*>) :: T r z (a -> b) -> T r z a -> T r z b #

liftA2 :: (a -> b -> c) -> T r z a -> T r z b -> T r z c #

(*>) :: T r z a -> T r z b -> T r z b #

(<*) :: T r z a -> T r z b -> T r z a #

Functor (T r z) Source # 
Instance details

Defined in LLVM.Extra.MaybeContinuation

Methods

fmap :: (a -> b) -> T r z a -> T r z b #

(<$) :: a -> T r z b -> T r z a #

Monad (T r z) Source # 
Instance details

Defined in LLVM.Extra.MaybeContinuation

Methods

(>>=) :: T r z a -> (a -> T r z b) -> T r z b #

(>>) :: T r z a -> T r z b -> T r z b #

return :: a -> T r z a #

map :: (a -> CodeGenFunction r b) -> T r z a -> T r z b Source #

withBool :: Phi z => Value Bool -> CodeGenFunction r a -> T r z a Source #

counterpart to Data.Maybe.HT.toMaybe

fromBool :: Phi z => CodeGenFunction r (Value Bool, a) -> T r z a Source #

fromPlainMaybe :: Phi z => T a -> T r z a Source #

fromMaybe :: Phi z => CodeGenFunction r (T a) -> T r z a Source #

toMaybe :: Undefined a => T r (T a) a -> CodeGenFunction r (T a) Source #

lift :: CodeGenFunction r a -> T r z a Source #

guard :: Phi z => Value Bool -> T r z () Source #

just :: a -> T r z a Source #

nothing :: T r z a Source #

bind :: T r z a -> (a -> T r z b) -> T r z b Source #

onFail :: CodeGenFunction r () -> T r z a -> T r z a Source #

Run an exception handler if the Maybe-action fails. The exception is propagated. That is, the handler is intended for a cleanup procedure.

alternative :: (Phi z, Undefined a) => T r (T a) a -> T r (T a) a -> T r z a Source #

Run the first action and if that fails run the second action. If both actions fail, then the composed action fails, too.

fixedLengthLoop :: (Phi s, Undefined s, Num i, IsConst i, IsInteger i, CmpRet i, IsPrimitive i) => Value i -> s -> (s -> T r (T s) s) -> CodeGenFunction r (Value i, T s) Source #

arrayLoop :: (Phi s, Undefined s, IsType a, Num i, IsConst i, IsInteger i, CmpRet i, IsPrimitive i) => Value i -> Value (Ptr a) -> s -> (Value (Ptr a) -> s -> T r (T (Value (Ptr a), s)) s) -> CodeGenFunction r (Value i, T s) Source #

If the returned position is smaller than the array size, then returned final state is nothing.

arrayLoop2 :: (Phi s, Undefined s, IsType a, IsType b, Num i, IsConst i, IsInteger i, CmpRet i, IsPrimitive i) => Value i -> Value (Ptr a) -> Value (Ptr b) -> s -> (Value (Ptr a) -> Value (Ptr b) -> s -> T r (T (Value (Ptr a), (Value (Ptr b), s))) s) -> CodeGenFunction r (Value i, T s) Source #