polysemy-several-0.1.1.0: Run several effects at once, taken from the polysemy-zoo.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Polysemy.Several

Synopsis

Documentation

data HList a where Source #

A list capable of storing values of different types. Creating an HList looks like.

1 ::: "test" ::: True ::: HNil

Constructors

HNil :: HList '[] 
(:::) :: a -> HList (b :: [Type]) -> HList (a ': b) infixr 5 

type family TypeMap (f :: a -> b) (xs :: [a]) where ... Source #

A map function over type level lists. For example, the following two lines are equivalent:

TypeMap Reader [Int, String, False]
[Reader Int, Reader String, Reader Bool]

Equations

TypeMap _ '[] = '[] 
TypeMap f (x ': xs) = f x ': TypeMap f xs 

type family Append (a :: [t]) (b :: [t]) where ... Source #

Type-level append.

Append [Int, String] [Bool]
[Int, String, Bool]

Equations

Append '[] b = b 
Append (a ': as) b = a ': Append as b 

runSeveral :: (forall r' k x. k -> Sem (e k ': r') x -> Sem r' x) -> HList t -> Sem (Append (TypeMap e t) r) a -> Sem r a Source #

A helper function for building new runners which accept HLists intsead of individual elements. If you would normally write

f 5 . f "Text" . f True

then this function can turn that into

runSeveral f (True ::: "Text" ::: 5 ::: HNil)

For example, a runReaders function could be implemented as:

runReaders :: HList t -> Sem (TypeConcat (TypeMap Reader t) r) a -> Sem r a
runReaders = runSeveral runReader

Since: 0.1.0.0