Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Control.Eff.Example
Description
Example usage of Control.Eff
Synopsis
- newtype TooBig = TooBig Int
- runErrBig :: forall (r :: [Type -> Type]) a. Eff ((Exc TooBig :: Type -> Type) ': r) a -> Eff r (Either TooBig a)
- sum2 :: forall (r :: [Type -> Type]). '[Reader Int, Reader Float] <:: r => Eff r Float
- writeAll :: forall a (e :: [Type -> Type]). Member (Writer a) e => [a] -> Eff e ()
- sumAll :: forall a (e :: [Type -> Type]). (Num a, Member (State a) e) => [a] -> Eff e ()
- writeAndAdd :: forall a (e :: [Type -> Type]). ('[Writer a, State a] <:: e, Num a) => [a] -> Eff e ()
- sumEff :: Num a => [a] -> a
- lastEff :: [a] -> Maybe a
- lastAndSum :: Num a => [a] -> (Maybe a, a)
- data Move x where
- handUp :: forall (r :: [Type -> Type]) a. Eff (Move ': r) a -> Eff r a
- handDown :: forall (r :: [Type -> Type]) a. Eff (Move ': r) a -> Eff r a
Documentation
The datatype for the example from the paper. See the tests for the example
runErrBig :: forall (r :: [Type -> Type]) a. Eff ((Exc TooBig :: Type -> Type) ': r) a -> Eff r (Either TooBig a) Source #
specialization to tell the type of the exception
sum2 :: forall (r :: [Type -> Type]). '[Reader Int, Reader Float] <:: r => Eff r Float Source #
Multiple Reader effects
writeAll :: forall a (e :: [Type -> Type]). Member (Writer a) e => [a] -> Eff e () Source #
Write the elements of a list of numbers, in order.
sumAll :: forall a (e :: [Type -> Type]). (Num a, Member (State a) e) => [a] -> Eff e () Source #
Add a list of numbers to the current state.
writeAndAdd :: forall a (e :: [Type -> Type]). ('[Writer a, State a] <:: e, Num a) => [a] -> Eff e () Source #
Write a list of numbers and add them to the current state.
lastEff :: [a] -> Maybe a Source #
Safely get the last element of a list. Nothing for empty lists; Just the last element otherwise.
lastAndSum :: Num a => [a] -> (Maybe a, a) Source #
Get the last element and sum of a list