License | MIT |
---|---|
Maintainer | dan.firth@homotopic.tech |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Extra convenience functions for polysemy.
Synopsis
- contramapInput :: forall i i' r a. Members '[Input i'] r => (i' -> i) -> Sem (Input i ': r) a -> Sem r a
- contramapInputSem :: forall i i' r a. Members '[Input i'] r => (i' -> Sem r i) -> Sem (Input i ': r) a -> Sem r a
- contramapInput' :: forall i i' r a. Members '[Input i'] r => (i' -> i) -> Sem (Input i ': r) a -> Sem (Input i' ': r) a
- runInputConstF :: forall b f r a. f b -> Sem (Input (f b) ': r) a -> Sem r a
- mapOutput :: Members '[Output o'] r => (o -> o') -> Sem (Output o ': r) a -> Sem r a
- mapOutputSem :: forall o o' r a. Members '[Output o'] r => (o -> Sem r o') -> Sem (Output o ': r) a -> Sem r a
- mapOutput' :: Members '[Output o'] r => (o -> o') -> Sem (Output o ': r) a -> Sem (Output o' ': r) a
- runOutputMapAsKVStore :: Members '[KVStore k v] r => Sem (Output (Map k v) ': r) a -> Sem r a
- runKVStoreAsKVStore :: forall k v k' v' r a. (k -> k') -> (v -> v') -> (v' -> v) -> Sem (KVStore k v ': r) a -> Sem (KVStore k' v' ': r) a
- runKVStoreAsKVStoreSem :: forall k v k' v' r a. Members '[KVStore k' v'] r => (k -> Sem r k') -> (v -> Sem r v') -> (v' -> Sem r v) -> Sem (KVStore k v ': r) a -> Sem r a
- raise4Under :: forall e5 e1 e2 e3 e4 r a. Sem (e1 ': (e2 ': (e3 ': (e4 ': r)))) a -> Sem (e1 ': (e2 ': (e3 ': (e4 ': (e5 ': r))))) a
- reinterpretUnder :: forall e1 e2 e3 r a. (forall m x. Sem (e2 ': m) x -> Sem (e3 ': m) x) -> Sem (e1 ': (e2 ': r)) a -> Sem (e1 ': (e3 ': r)) a
- reinterpretUnder2 :: forall e1 e2 e3 e4 r a. (forall m x. Sem (e3 ': m) x -> Sem (e4 ': m) x) -> Sem (e1 ': (e2 ': (e3 ': r))) a -> Sem (e1 ': (e2 ': (e4 ': r))) a
- reinterpret2Under :: forall e1 e2 e3 e4 r a. (forall m x. Sem (e2 ': m) x -> Sem (e3 ': (e4 ': m)) x) -> Sem (e1 ': (e2 ': r)) a -> Sem (e1 ': (e3 ': (e4 ': r))) a
- rotateEffects2 :: forall e1 e2 r a. Sem (e1 ': (e2 ': r)) a -> Sem (e2 ': (e1 ': r)) a
- rotateEffects3L :: forall e1 e2 e3 r a. Sem (e1 ': (e2 ': (e3 ': r))) a -> Sem (e2 ': (e3 ': (e1 ': r))) a
- rotateEffects3R :: forall e1 e2 e3 r a. Sem (e1 ': (e2 ': (e3 ': r))) a -> Sem (e3 ': (e1 ': (e2 ': r))) a
- rotateEffects4L :: forall e1 e2 e3 e4 r a. Sem (e1 ': (e2 ': (e3 ': (e4 ': r)))) a -> Sem (e2 ': (e3 ': (e4 ': (e1 ': r)))) a
- rotateEffects4R :: forall e1 e2 e3 e4 r a. Sem (e1 ': (e2 ': (e3 ': (e4 ': r)))) a -> Sem (e4 ': (e1 ': (e2 ': (e3 ': r)))) a
- reverseEffects2 :: forall e1 e2 r a. Sem (e1 ': (e2 ': r)) a -> Sem (e2 ': (e1 ': r)) a
- reverseEffects3 :: forall e1 e2 e3 r a. Sem (e1 ': (e2 ': (e3 ': r))) a -> Sem (e3 ': (e2 ': (e1 ': r))) a
- reverseEffects4 :: forall e1 e2 e3 e4 r a. Sem (e1 ': (e2 ': (e3 ': (e4 ': r)))) a -> Sem (e4 ': (e3 ': (e2 ': (e1 ': r)))) a
- irrefutableAbsorbThrow :: forall e r a. (Exception e, Members '[Error e] r) => (forall m. MonadThrow m => m a) -> Sem r a
Input
:: 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
:: 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
:: 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
:: 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
:: 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
:: 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 #
KVStore
:: 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 |
runKVStoreAsKVStoreSem Source #
:: 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 |
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
:: 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
:: 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
:: 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 #