Feldspar.Option

feldspar-language-0.6.0.2: A functional embedded language for DSP and parallelism

Safe Haskell | None

Feldspar.Option

Contents

- Conditional choice operator

Synopsis

- data Option a = Option {
  - isSome :: Data Bool
  - fromSome :: a
  }
- desugarOption :: Type a => Option (Data a) -> Data (Bool, a)
- sugarOption :: Type a => Data (Bool, a) -> Option (Data a)
- some :: a -> Option a
- none :: Syntax a => Option a
- option :: Syntax b => b -> (a -> b) -> Option a -> b
- oplus :: Syntax a => Option a -> Option a -> Option a
- (?>) :: Data Bool -> a -> Option a
- (<?) :: Syntax a => a -> Option a -> a

# Documentation

data Option a

Constructors

Option |
Fields isSome :: Data Bool fromSome :: a

Instances

Monad Option |
Functor Option |
Syntax a => Syntactic (Option a) |
Syntax a => Syntax (Option a) |

desugarOption :: Type a => Option (Data a) -> Data (Bool, a)

One-layer desugaring of `Option`

sugarOption :: Type a => Data (Bool, a) -> Option (Data a)

One-layer sugaring of `Option`

some :: a -> Option a

none :: Syntax a => Option a

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

oplus :: Syntax a => Option a -> Option a -> Option a

# Conditional choice operator

(?>) :: Data Bool -> a -> Option a

Conditional choice operator. Can be used together with `<?` to write guarded choices as follows:

     prog :: Data Index -> Data Index
     prog a
         =  a+1 <? a==0
         ?> a+2 <? a==1
         ?> a+3 <? a==2
         ?> a+4 <? a==3
         ?> a+5

(<?) :: Syntax a => a -> Option a -> a