polysemy-extra-0.1.7.0: Extra Input and Output functions for polysemy..
LicenseMIT
Maintainerdan.firth@homotopic.tech
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Polysemy.Extra

Description

Extra convenience functions for polysemy.

Synopsis

Input

contramapInput Source #

Arguments

:: forall i i' r a. Members '[Input i'] r 
=> (i' -> i)

A function to map the new input to the old input.

-> Sem (Input i ': r) a 
-> Sem r a 

Map an Input contravariantly.

Since: 0.1.0.0

contramapInputSem Source #

Arguments

:: forall i i' r a. Members '[Input i'] r 
=> (i' -> Sem r i)

A function to map the new input to the old input.

-> Sem (Input i ': r) a 
-> Sem r a 

Map an Input contravariantly through a monadic function. @since 0.1.0.0

contramapInput' Source #

Arguments

:: forall i i' r a. Members '[Input i'] r 
=> (i' -> i)

A function to map the new input to the old input.

-> Sem (Input i ': r) a 
-> Sem (Input i' ': r) a 

Reinterpreting version of contramapInput.

Since: 0.1.4.0

runInputConstF :: forall b f r a. f b -> Sem (Input (f b) ': r) a -> Sem r a Source #

Like runInputConst, except with a type parameter for the functor for abusing type applications.

Since: 0.1.5.0

Output

mapOutput Source #

Arguments

:: Members '[Output o'] r 
=> (o -> o')

A function to map the old output to the new output.

-> Sem (Output o ': r) a 
-> Sem r a 

Map an Output covariantly.

Since: 0.1.0.0

mapOutputSem Source #

Arguments

:: forall o o' r a. Members '[Output o'] r 
=> (o -> Sem r o')

A function to map the old output to the new output.

-> Sem (Output o ': r) a 
-> Sem r a 

Map an Output covariantly through a monadic function.

Since: 0.1.0.0

mapOutput' Source #

Arguments

:: Members '[Output o'] r 
=> (o -> o')

A function to map the old output to the new output.

-> Sem (Output o ': r) a 
-> Sem (Output o' ': r) a 

Reinterpreting version of mapOutput.

Since: 0.1.4.0

runOutputMapAsKVStore :: Members '[KVStore k v] r => Sem (Output (Map k v) ': r) a -> Sem r a Source #

Run an Output (Map k v) as a KVStore by writing the values to the keys.

Since: 0.1.0.0

KVStore

runKVStoreAsKVStore Source #

Arguments

:: forall k v k' v' r a. (k -> k')

A function to transform the key into the interpreted key.

-> (v -> v')

A function to transform the value into the interpreted value.

-> (v' -> v)

A function to transform the interpreted key back into the current value.

-> Sem (KVStore k v ': r) a 
-> Sem (KVStore k' v' ': r) a 

Run a KVStore in terms of another KVStore by way of pure key and value transformations.

Since: 0.1.0.0

runKVStoreAsKVStoreSem Source #

Arguments

:: forall k v k' v' r a. Members '[KVStore k' v'] r 
=> (k -> Sem r k')

A function to transform the key into the interpreted key.

-> (v -> Sem r v')

A function to transform the value into the interpreted value.

-> (v' -> Sem r v)

A function to transform the interpreted value back into the current value.

-> Sem (KVStore k v ': r) a 
-> Sem r a 

Run a KVStore in terms of another KVStore by way of transforming the keys and values with Sem functions.

Since: 0.1.0.0

Raise

raise4Under :: forall e5 e1 e2 e3 e4 r a. Sem (e1 ': (e2 ': (e3 ': (e4 ': r)))) a -> Sem (e1 ': (e2 ': (e3 ': (e4 ': (e5 ': r))))) a Source #

Like raise, but introduces an effect four levels underneath the head of the list.

Since: 0.1.3.0

Reinterpreters

reinterpretUnder Source #

Arguments

:: forall e1 e2 e3 r a. (forall m x. Sem (e2 ': m) x -> Sem (e3 ': m) x)

A natural transformation from the handled effect to the new effects.

-> Sem (e1 ': (e2 ': r)) a 
-> Sem (e1 ': (e3 ': r)) a 

Reinterpret the second effect in the stack into a single effect.

Since: 0.1.1.0

reinterpretUnder2 Source #

Arguments

:: forall e1 e2 e3 e4 r a. (forall m x. Sem (e3 ': m) x -> Sem (e4 ': m) x)

A natural transformation from the handled effect to the new effects.

-> Sem (e1 ': (e2 ': (e3 ': r))) a 
-> Sem (e1 ': (e2 ': (e4 ': r))) a 

Reinterpret the third effect in the stack into a single effect.

Since: 0.1.1.0

reinterpret2Under Source #

Arguments

:: forall e1 e2 e3 e4 r a. (forall m x. Sem (e2 ': m) x -> Sem (e3 ': (e4 ': m)) x)

A natural transformation from the handled effect to the new effects.

-> Sem (e1 ': (e2 ': r)) a 
-> Sem (e1 ': (e3 ': (e4 ': r))) a 

Reinterpret the second effect in the stack in terms of two effects.

Since: 0.1.1.0

Rotation

rotateEffects2 :: forall e1 e2 r a. Sem (e1 ': (e2 ': r)) a -> Sem (e2 ': (e1 ': r)) a Source #

Swap the positions of the first two effects in the stack.

Since: 0.1.2.0

rotateEffects3L :: forall e1 e2 e3 r a. Sem (e1 ': (e2 ': (e3 ': r))) a -> Sem (e2 ': (e3 ': (e1 ': r))) a Source #

Rotate the first three effects in the stack to the left.

Since: 0.1.2.0

rotateEffects3R :: forall e1 e2 e3 r a. Sem (e1 ': (e2 ': (e3 ': r))) a -> Sem (e3 ': (e1 ': (e2 ': r))) a Source #

Rotate the first three effects in the stack to the right.

Since: 0.1.2.0

rotateEffects4L :: forall e1 e2 e3 e4 r a. Sem (e1 ': (e2 ': (e3 ': (e4 ': r)))) a -> Sem (e2 ': (e3 ': (e4 ': (e1 ': r)))) a Source #

Rotate the first four effects in the stack to the left.

Since: 0.1.3.0

rotateEffects4R :: forall e1 e2 e3 e4 r a. Sem (e1 ': (e2 ': (e3 ': (e4 ': r)))) a -> Sem (e4 ': (e1 ': (e2 ': (e3 ': r)))) a Source #

Rotate the first four effects in the stack to the right.

Since: 0.1.3.0

Reverse

reverseEffects2 :: forall e1 e2 r a. Sem (e1 ': (e2 ': r)) a -> Sem (e2 ': (e1 ': r)) a Source #

Reverse the position of the first two effects in the stack, equivalent to rotateEffects2.

Since: 0.1.3.0

reverseEffects3 :: forall e1 e2 e3 r a. Sem (e1 ': (e2 ': (e3 ': r))) a -> Sem (e3 ': (e2 ': (e1 ': r))) a Source #

Reverse the position of the first three effects in the stack.

Since: 0.1.3.0

reverseEffects4 :: forall e1 e2 e3 e4 r a. Sem (e1 ': (e2 ': (e3 ': (e4 ': r)))) a -> Sem (e4 ': (e3 ': (e2 ': (e1 ': r)))) a Source #

Reverse the position of the first four effects in the stack.

Since: 0.1.3.0

Exceptions

irrefutableAbsorbThrow :: forall e r a. (Exception e, Members '[Error e] r) => (forall m. MonadThrow m => m a) -> Sem r a Source #

Irrefutably absorb a MonadThrow constraint as a particular Exception type. This is useful for translating functions that you know use only use one error type. For more complicated uses of MonadThrow it's probably best to just rewrite the function in terms of Sem.

Since: 0.1.7.0