Safe Haskell | None |
---|---|
Language | Haskell2010 |
LiveCoding.Exceptions.Finite
Documentation
A type class for datatypes on which exception handling can branch statically.
These are exactly finite algebraic datatypes,
i.e. those defined from sums and products without recursion.
If you have a datatype with a Data
instance,
and there is no recursion in it,
then it is probably finite.
Let us assume your data type is:
data Foo = Bar | Baz { baz1 :: Bool, baz2 :: Maybe () }
To define the instance you need to add these two lines of boilerplate (possibly you need to import GHC.Generics and enable some language extensions):
deriving instance Generic Foo instance Finite Foo
Minimal complete definition
Nothing
Methods
commute :: forall (m :: Type -> Type) a b. Monad m => (e -> Cell m a b) -> Cell (ReaderT e m) a b Source #
class GFinite (f :: Type -> Type) where Source #
Methods
gcommute :: forall (m :: Type -> Type) e a b. Monad m => (f e -> Cell m a b) -> Cell (ReaderT (f e) m) a b Source #