llvm-extra-0.3: Utility functions for the llvm interface

LLVM.Extra.MaybeContinuation

Description

Maybe 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

resolve :: CodeGenFunction r z -> (a -> CodeGenFunction r z) -> CodeGenFunction r z
 

Instances

Monad (T r z) 
Functor (T r z) 
Applicative (T r z) 
MonadIO (T r z) 

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

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

counterpart to Data.Maybe.HT.toMaybe

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

lift :: CodeGenFunction r a -> T r z aSource

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

bind :: T r z a -> (a -> T r z b) -> T r z bSource

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

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

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

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