Home

Awesome

Free Build Status npm Version Code Coverage Code Climate License

Combination of a Free applicative functor and Free monad.

API

Types

data Par f a where
  Pure :: a -> Par f a
  Lift :: f a -> Par f a
  Ap :: Par f (a -> b) -> Par f a -> Par f b

data Seq f a where
  Pure :: a -> Seq f a
  Lift :: f a -> Seq f a
  Roll :: Seq f a -> (a -> Seq f b) -> Seq f b

data Concurrent f a where
  Lift :: f a -> Concurrent f a
  Seq  :: Seq (Concurrent f) a -> Concurrent f a
  Par  :: Par (Concurrent f) a -> Concurrent f a

data Interpreter f g m = Interpreter
  { runSeq :: Ɐ x. f x -> m x
  , runPar :: Ɐ x. f x -> g x
  , seqToPar :: Ɐ x. m x -> g x
  , parToSeq :: Ɐ x. g x -> m x
  , Par :: TypeRep g
  , Seq :: TypeRep m
  }

Asymptotic complexity

On all structures, complexity of:

Concurrent

Implements Functor, Applicative, ChainRec and Monad specifications.

It holds Parallel or Sequential computations which are itself holding Concurrent computations. When operating on Concurrent structures it's behaving as Sequential. but in cases you want Parallel behaviour you can call .par() on it and it will return Par object which is only Applicative. then you can move back to Concurrent using Concurrent.fromPar.

Functor, Applicative, ChainRec and Monad functions:

other functions:

Seq

Implements Functor, Applicative, ChainRec and Monad specifications.

Functor, Applicative, ChainRec and Monad functions:

other functions:

Par

Implements Functor and Applicative specifications.

Functor, Applicative, ChainRec and Monad functions:

other functions:

graft, hoist, retract and fold relations:

same for graftPar, graftSeq ... variations


This initial version of this module was based on a bit older version of srijs/haskell-free-concurrent, but it was not lawful, and from v2 it's based on more resent lawful version.