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

LiveCoding.Cell

Description

 
Synopsis

Documentation

data Cell m a b Source #

The basic building block of a live program.

You can build cells directly, by using constructors, or through the Functor, Applicative, or Arrow type classes.

The Cell constructor is the main way build a cell, but for efficiency purposes there is an additional constructor.

Constructors

forall s.Data s => Cell

A cell consists of an internal state, and an effectful state transition function.

Fields

ArrM

Effectively a cell with trivial state. Added to improve performance and keep state types simpler.

Fields

Instances

Instances details
Monad m => Arrow (Cell m) Source # 
Instance details

Defined in LiveCoding.Cell

Methods

arr :: (b -> c) -> Cell m b c #

first :: Cell m b c -> Cell m (b, d) (c, d) #

second :: Cell m b c -> Cell m (d, b) (d, c) #

(***) :: Cell m b c -> Cell m b' c' -> Cell m (b, b') (c, c') #

(&&&) :: Cell m b c -> Cell m b c' -> Cell m b (c, c') #

Monad m => ArrowChoice (Cell m) Source # 
Instance details

Defined in LiveCoding.Cell

Methods

left :: Cell m b c -> Cell m (Either b d) (Either c d) #

right :: Cell m b c -> Cell m (Either d b) (Either d c) #

(+++) :: Cell m b c -> Cell m b' c' -> Cell m (Either b b') (Either c c') #

(|||) :: Cell m b d -> Cell m c d -> Cell m (Either b c) d #

MonadFix m => ArrowLoop (Cell m) Source # 
Instance details

Defined in LiveCoding.Cell

Methods

loop :: Cell m (b, d) (c, d) -> Cell m b c #

Monad m => Category (Cell m :: Type -> Type -> Type) Source # 
Instance details

Defined in LiveCoding.Cell

Methods

id :: forall (a :: k). Cell m a a #

(.) :: forall (b :: k) (c :: k) (a :: k). Cell m b c -> Cell m a b -> Cell m a c #

toCell :: Functor m => Cell m a b -> Cell m a b Source #

Converts every Cell to the Cell constructor. Semantically, it is the identity function.

step :: Monad m => Cell m a b -> a -> m (b, Cell m a b) Source #

Execute a cell for one step.

steps :: Monad m => Cell m a b -> [a] -> m ([b], Cell m a b) Source #

Execute a cell for several steps. The number of steps is determined by the length of the list of inputs.

sumC :: (Monad m, Num a, Data a) => Cell m a a Source #

Add all inputs and return the delayed sum.

liveCell :: Monad m => Cell m () () -> LiveProgram m Source #

Convert a cell with no inputs and outputs to a live program. Semantically, this is an isomorphism.

toLiveCell :: Functor m => LiveProgram m -> Cell m () () Source #

The inverse to liveCell.

data Composition state1 state2 Source #

Constructors

Composition 

Fields

Instances

Instances details
(Data state1, Data state2) => Data (Composition state1 state2) Source # 
Instance details

Defined in LiveCoding.Cell

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Composition state1 state2 -> c (Composition state1 state2) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Composition state1 state2) #

toConstr :: Composition state1 state2 -> Constr #

dataTypeOf :: Composition state1 state2 -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Composition state1 state2)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Composition state1 state2)) #

gmapT :: (forall b. Data b => b -> b) -> Composition state1 state2 -> Composition state1 state2 #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Composition state1 state2 -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Composition state1 state2 -> r #

gmapQ :: (forall d. Data d => d -> u) -> Composition state1 state2 -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Composition state1 state2 -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Composition state1 state2 -> m (Composition state1 state2) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Composition state1 state2 -> m (Composition state1 state2) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Composition state1 state2 -> m (Composition state1 state2) #

type Sensor a = Cell IO () a Source #

type SF a b = forall m. Cell m a b Source #

type Actuator b = Cell IO b () Source #

stepRate :: Num a => a Source #

integrate :: (Data a, Fractional a, Monad m) => Cell m a a Source #

localTime :: (Data a, Fractional a, Monad m) => Cell m b a Source #

hoistCell :: (forall x. m1 x -> m2 x) -> Cell m1 a b -> Cell m2 a b Source #

Hoist a Cell along a monad morphism.

liftCell :: (Monad m, MonadTrans t) => Cell m a b -> Cell (t m) a b Source #

Lift a Cell into a monad transformer.

data Parallel stateP1 stateP2 Source #

Constructors

Parallel 

Fields

Instances

Instances details
(Data stateP1, Data stateP2) => Data (Parallel stateP1 stateP2) Source # 
Instance details

Defined in LiveCoding.Cell

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Parallel stateP1 stateP2 -> c (Parallel stateP1 stateP2) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Parallel stateP1 stateP2) #

toConstr :: Parallel stateP1 stateP2 -> Constr #

dataTypeOf :: Parallel stateP1 stateP2 -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Parallel stateP1 stateP2)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Parallel stateP1 stateP2)) #

gmapT :: (forall b. Data b => b -> b) -> Parallel stateP1 stateP2 -> Parallel stateP1 stateP2 #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Parallel stateP1 stateP2 -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Parallel stateP1 stateP2 -> r #

gmapQ :: (forall d. Data d => d -> u) -> Parallel stateP1 stateP2 -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Parallel stateP1 stateP2 -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Parallel stateP1 stateP2 -> m (Parallel stateP1 stateP2) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Parallel stateP1 stateP2 -> m (Parallel stateP1 stateP2) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Parallel stateP1 stateP2 -> m (Parallel stateP1 stateP2) #

arrM :: (a -> m b) -> Cell m a b Source #

constM :: m b -> Cell m a b Source #

constC :: Monad m => b -> Cell m a b Source #

data Choice stateL stateR Source #

Constructors

Choice 

Fields

Instances

Instances details
(Data stateL, Data stateR) => Data (Choice stateL stateR) Source # 
Instance details

Defined in LiveCoding.Cell

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Choice stateL stateR -> c (Choice stateL stateR) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Choice stateL stateR) #

toConstr :: Choice stateL stateR -> Constr #

dataTypeOf :: Choice stateL stateR -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Choice stateL stateR)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Choice stateL stateR)) #

gmapT :: (forall b. Data b => b -> b) -> Choice stateL stateR -> Choice stateL stateR #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Choice stateL stateR -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Choice stateL stateR -> r #

gmapQ :: (forall d. Data d => d -> u) -> Choice stateL stateR -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Choice stateL stateR -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Choice stateL stateR -> m (Choice stateL stateR) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Choice stateL stateR -> m (Choice stateL stateR) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Choice stateL stateR -> m (Choice stateL stateR) #