raw-feldspar-0.1: Resource-Aware Feldspar

Feldspar.Data.Option

Description

Optional values

Synopsis

# Documentation

data OptionT m a Source #

Transformer version of Option

Instances

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.

Arguments

 :: Syntax b => (String -> b) none case -> (a -> b) some case -> Option a -> b

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

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

Arguments

 :: MonadComp m => (String -> m ()) none case -> (a -> m ()) some case -> Option a -> m ()

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

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

Arguments

 :: MonadComp m => (String -> m ()) none case -> (a -> m ()) some case -> OptionT m a -> m ()

Deconstruct an OptionT value

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