raw-feldspar-0.1: Resource-Aware Feldspar

Safe HaskellNone
LanguageHaskell2010

Feldspar.Data.Option

Description

Optional values

Synopsis

Documentation

data OptionT m a Source #

Transformer version of Option

Instances

MonadTrans OptionT Source # 

Methods

lift :: Monad m => m a -> OptionT m a #

Monad m => Monad (OptionT m) Source # 

Methods

(>>=) :: OptionT m a -> (a -> OptionT m b) -> OptionT m b #

(>>) :: OptionT m a -> OptionT m b -> OptionT m b #

return :: a -> OptionT m a #

fail :: String -> OptionT m a #

Monad m => Functor (OptionT m) Source # 

Methods

fmap :: (a -> b) -> OptionT m a -> OptionT m b #

(<$) :: a -> OptionT m b -> OptionT m a #

Monad m => Applicative (OptionT m) Source # 

Methods

pure :: a -> OptionT m a #

(<*>) :: OptionT m (a -> b) -> OptionT m a -> OptionT m b #

(*>) :: OptionT m a -> OptionT m b -> OptionT m b #

(<*) :: OptionT m a -> OptionT m b -> OptionT m a #

Syntax a => Syntactic (Option a) Source # 

Associated Types

type Domain (Option a) :: * -> * #

type Internal (Option a) :: * #

Methods

desugar :: Option a -> ASTF (Domain (Option a)) (Internal (Option a)) #

sugar :: ASTF (Domain (Option a)) (Internal (Option a)) -> Option a #

MonadComp m => MonadComp (OptionT m) Source # 

Methods

liftComp :: Comp a -> OptionT m a Source #

iff :: Data Bool -> OptionT m () -> OptionT m () -> OptionT m () Source #

for :: (Integral n, PrimType n) => IxRange (Data n) -> (Data n -> OptionT m ()) -> OptionT m () Source #

while :: OptionT m (Data Bool) -> OptionT m () -> OptionT m () Source #

(Storable a, Syntax a, (~) * (StoreSize a) ()) => Storable (Option a) Source # 

Associated Types

type StoreRep (Option a) :: * Source #

type StoreSize (Option a) :: * Source #

Syntax a => Forcible (Option a) Source # 

Associated Types

type ValueRep (Option a) :: * Source #

type Internal (Option a) Source # 
type Internal (Option a) = (Bool, Internal a)
type Domain (Option a) Source # 
type StoreRep (Option a) Source # 
type StoreRep (Option a) = (DRef Bool, StoreRep a)
type StoreSize (Option a) Source # 
type StoreSize (Option a) = ()
type ValueRep (Option a) Source # 
type ValueRep (Option a) = (Data Bool, a)

type Option = OptionT Identity Source #

Optional value, analogous to Either String a in normal Haskell

none :: String -> OptionT m a Source #

Construct a missing Option value (analogous to Left in normal Haskell)

some :: Monad m => a -> OptionT m a Source #

Construct a present Option value (analogous to Right in normal Haskell)

guardO :: String -> Data Bool -> OptionT m () Source #

Construct an Option that is either none or some () depending on the Boolean guard

In the expression guardO c >> rest, the action rest will not be executed unless c is true.

guarded :: Monad m => String -> Data Bool -> a -> OptionT m a Source #

Construct an Option from a guard and a value. The value will not be evaluated if the guard is false.

option Source #

Arguments

:: Syntax b 
=> (String -> b)

none case

-> (a -> b)

some case

-> Option a 
-> b 

Deconstruct an Option value (analogous to either in normal Haskell)

caseOption Source #

Arguments

:: Syntax b 
=> Option a 
-> (String -> b)

none case

-> (a -> b)

some case

-> b 

Deconstruct an Option value

fromSome :: Syntax a => Option a -> a Source #

Extract the value of an Option that is assumed to be present

optionM Source #

Arguments

:: MonadComp m 
=> (String -> m ())

none case

-> (a -> m ())

some case

-> Option a 
-> m () 

Deconstruct an Option value (analogous to maybe in normal Haskell)

caseOptionM Source #

Arguments

:: MonadComp m 
=> Option a 
-> (String -> m ())

none case

-> (a -> m ())

some case

-> m () 

Deconstruct an Option value

fromSomeM :: (Syntax a, MonadComp m) => Option a -> m a Source #

Extract the value of an Option that is assumed to be present

optionT Source #

Arguments

:: MonadComp m 
=> (String -> m ())

none case

-> (a -> m ())

some case

-> OptionT m a 
-> m () 

Deconstruct an OptionT value

caseOptionT Source #

Arguments

:: MonadComp m 
=> OptionT m a 
-> (String -> m ())

none case

-> (a -> m ())

some case

-> m () 

Deconstruct an OptionT value

fromSomeT :: (Syntax a, MonadComp m) => OptionT m a -> m a Source #

Extract the value of an OptionT that is assumed to be present