essence-of-live-coding-0.2.6: General purpose live coding framework
Safe HaskellSafe-Inferred
LanguageHaskell2010

LiveCoding.Exceptions.Finite

Synopsis

Documentation

class Finite e where Source #

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 :: Monad m => (e -> Cell m a b) -> Cell (ReaderT e m) a b Source #

default commute :: (Generic e, GFinite (Rep e), Monad m) => (e -> Cell m a b) -> Cell (ReaderT e m) a b Source #

Instances

Instances details
Finite Bool Source # 
Instance details

Defined in LiveCoding.Exceptions.Finite

Methods

commute :: forall (m :: Type -> Type) a b. Monad m => (Bool -> Cell m a b) -> Cell (ReaderT Bool m) a b Source #

Finite () Source # 
Instance details

Defined in LiveCoding.Exceptions.Finite

Methods

commute :: forall (m :: Type -> Type) a b. Monad m => (() -> Cell m a b) -> Cell (ReaderT () m) a b Source #

Finite Void Source # 
Instance details

Defined in LiveCoding.Exceptions.Finite

Methods

commute :: forall (m :: Type -> Type) a b. Monad m => (Void -> Cell m a b) -> Cell (ReaderT Void m) a b Source #

(Finite e1, Finite e2) => Finite (Either e1 e2) Source # 
Instance details

Defined in LiveCoding.Exceptions.Finite

Methods

commute :: forall (m :: Type -> Type) a b. Monad m => (Either e1 e2 -> Cell m a b) -> Cell (ReaderT (Either e1 e2) m) a b Source #

class GFinite f where Source #

Methods

gcommute :: Monad m => (f e -> Cell m a b) -> Cell (ReaderT (f e) m) a b Source #

Instances

Instances details
GFinite (V1 :: Type -> Type) Source # 
Instance details

Defined in LiveCoding.Exceptions.Finite

Methods

gcommute :: forall (m :: Type -> Type) e a b. Monad m => (V1 e -> Cell m a b) -> Cell (ReaderT (V1 e) m) a b Source #

GFinite (U1 :: Type -> Type) Source # 
Instance details

Defined in LiveCoding.Exceptions.Finite

Methods

gcommute :: forall (m :: Type -> Type) e a b. Monad m => (U1 e -> Cell m a b) -> Cell (ReaderT (U1 e) m) a b Source #

Finite e => GFinite (K1 a e :: Type -> Type) Source # 
Instance details

Defined in LiveCoding.Exceptions.Finite

Methods

gcommute :: forall (m :: Type -> Type) e0 a0 b. Monad m => (K1 a e e0 -> Cell m a0 b) -> Cell (ReaderT (K1 a e e0) m) a0 b Source #

(GFinite eL, GFinite eR) => GFinite (eL :+: eR) Source # 
Instance details

Defined in LiveCoding.Exceptions.Finite

Methods

gcommute :: forall (m :: Type -> Type) e a b. Monad m => ((eL :+: eR) e -> Cell m a b) -> Cell (ReaderT ((eL :+: eR) e) m) a b Source #

(GFinite e1, GFinite e2) => GFinite (e1 :*: e2) Source # 
Instance details

Defined in LiveCoding.Exceptions.Finite

Methods

gcommute :: forall (m :: Type -> Type) e a b. Monad m => ((e1 :*: e2) e -> Cell m a b) -> Cell (ReaderT ((e1 :*: e2) e) m) a b Source #

GFinite f => GFinite (M1 a b f) Source # 
Instance details

Defined in LiveCoding.Exceptions.Finite

Methods

gcommute :: forall (m :: Type -> Type) e a0 b0. Monad m => (M1 a b f e -> Cell m a0 b0) -> Cell (ReaderT (M1 a b f e) m) a0 b0 Source #