polysemy-methodology-0.2.2.0: Domain modelling algebra for polysemy
LicenseMIT
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Polysemy.Methodology

Description

Domain modelling algebra for polysemy.

Synopsis

Definition

data Methodology b c m a where Source #

A Methodology generalises a semantic process from b to c.

Constructors

Process :: b -> Methodology b c m c 

process :: forall b c r. Member (Methodology b c) r => b -> Sem r c Source #

Eliminators

runMethodologyPure Source #

Arguments

:: forall b c r a. (b -> c)

A function from b to c.

-> Sem (Methodology b c ': r) a 
-> Sem r a 

Run a Methodology using a pure function.

Since: 0.1.0.0

runMethodologySem Source #

Arguments

:: forall b c r a. (b -> Sem r c)

A monadic function from b to c using effects in r.

-> Sem (Methodology b c ': r) a 
-> Sem r a 

Run a Methodology using a monadic function with effects in r.

Since: 0.1.0.0

Decomposition

cutMethodology Source #

Arguments

:: forall b c d r a. Members '[Methodology b c, Methodology c d] r 
=> Sem (Methodology b d ': r) a

Methodology effect to decompose.

-> Sem r a 

Cut a Methodology into two pieces at a midpoint.

Since: 0.1.0.0

cutMethodology' Source #

Arguments

:: forall b c d r a. Sem (Methodology b d ': r) a

Methodology effect to decompose.

-> Sem (Methodology b c ': (Methodology c d ': r)) a 

Reinterpreting version of cutMethodology.

Since: 0.1.6.0

cutMethodology3 Source #

Arguments

:: forall b c d e r a. Members '[Methodology b c, Methodology c d, Methodology d e] r 
=> Sem (Methodology b e ': r) a

Methodology effect to decompose.

-> Sem r a 

Cut a Methodology into three pieces using two cuts.

Since: 0.1.0.0

cutMethodology3' Source #

Arguments

:: forall b c d e r a. Sem (Methodology b d ': r) a

Methodology effect to decompose.

-> Sem (Methodology b c ': (Methodology c d ': (Methodology d e ': r))) a 

Reinterpreting version of cutMethodology.

Since: 0.1.6.0

divideMethodology Source #

Arguments

:: forall b c c' d r a. Members '[Methodology b c, Methodology b c', Methodology (c, c') d] r 
=> Sem (Methodology b d ': r) a

Methodology effect to decompose.

-> Sem r a 

Divide a Methodology into two components using a Methodology that accepts a pair.`

Since: 0.1.0.0

divideMethodology' :: forall b c c' d r a. Sem (Methodology b d ': r) a -> Sem (Methodology b c ': (Methodology b c' ': (Methodology (c, c') d ': r))) a Source #

Reinterpreting version of divideMethodology.

Since: 0.1.6.0

decideMethodology Source #

Arguments

:: forall b c c' d r a. Members '[Methodology b (Either c c'), Methodology c d, Methodology c' d] r 
=> Sem (Methodology b d ': r) a

`Methodology effect to decompose.

-> Sem r a 

Decide between two Methodologys using a Methodology that computes an Either.

Since: 0.1.0.0

decideMethodology' :: forall b c c' d r a. Sem (Methodology b d ': r) a -> Sem (Methodology b (Either c c') ': (Methodology c d ': (Methodology c' d ': r))) a Source #

Reinterpreting version of decideMethodology.

Since: 0.1.6.0

decomposeMethodology :: forall b f c r a. Members '[Methodology b (HList f), Methodology (HList f) c] r => Sem (Methodology b c ': r) a -> Sem r a Source #

Decompose a Methodology into several components to be recombined. This is cutMethodology specialised to HList.

Since: 0.1.0.0

decomposeMethodology' :: forall b f c r a. Sem (Methodology b c ': r) a -> Sem (Methodology b (HList f) ': (Methodology (HList f) c ': r)) a Source #

Reinterpreting version of decomposeMethodology.

Since: 0.1.6.0

decomposeMethodology3 :: forall b f g c r a. Members '[Methodology b (HList f), Methodology (HList f) (HList g), Methodology (HList g) c] r => Sem (Methodology b c ': r) a -> Sem r a Source #

Decompose a Methodology into several components over three sections with two cuts.

Since: 0.1.0.0

separateMethodologyInitial :: forall b x xs r a. Members '[Methodology b (HList xs), Methodology b x] r => Sem (Methodology b (HList (x ': xs)) ': r) a -> Sem r a Source #

Factor a Methodology decomposed over an HList in the result by a Methodology to the first variable.

Since: 0.1.0.0

endMethodologyInitial :: Sem (Methodology b (HList '[]) ': r) a -> Sem r a Source #

Finish an HList separated Methodology by consuming it for no effect.

Since: 0.1.0.0

separateMethodologyTerminal :: forall x c xs r a. (Monoid c, Members '[Methodology (HList xs) c, Methodology x c] r) => Sem (Methodology (HList (x ': xs)) c ': r) a -> Sem r a Source #

Factor a Methodology decomposed over an HList in the source by a Methodology from the first variable. Assumes the result is a Monoid.

Since: 0.1.0.0

endMethodologyTerminal :: Monoid c => Sem (Methodology (HList '[]) c ': r) a -> Sem r a Source #

Finalise an HList separated Methodology in the source by returning the Monoid unit.

Since: 0.1.0.0

Simplifcation

fmapMethodology :: forall f b c r a. (Members '[Methodology b c] r, Traversable f) => Sem (Methodology (f b) (f c) ': r) a -> Sem r a Source #

Run a Methodology (f b) (f c) by way of a Methodology b c. Note that f must be Traversable.

Since: 0.1.2.0

fmapMethodology' :: forall f b c r a. Traversable f => Sem (Methodology (f b) (f c) ': r) a -> Sem (Methodology b c ': r) a Source #

Reinterpreting version of fmapMethodology.

Since: 0.1.6.0

fmap2Methodology :: forall f g b c r a. (Members '[Methodology b c] r, Traversable f, Traversable g) => Sem (Methodology (f (g b)) (f (g c)) ': r) a -> Sem r a Source #

Run a Methodology (f (g b)) (f (g c))) by way of a Methodology b c. Note that f and g must be Traversable.

Since: 0.1.2.0

fmap2Methodology' :: forall f g b c r a. (Traversable f, Traversable g) => Sem (Methodology (f (g b)) (f (g c)) ': r) a -> Sem (Methodology b c ': r) a Source #

Reinterpreting version of fmap2Methodology.

Since: 0.1.6.0

pureMethodology :: forall f b c r a. (Members '[Methodology b c] r, Applicative f) => Sem (Methodology b (f c) ': r) a -> Sem r a Source #

Run a Methodology b (f c) in terms of a Methodology b c.

Since: 0.1.7.0

pureMethodology' :: forall f b c r a. Applicative f => Sem (Methodology b (f c) ': r) a -> Sem (Methodology b c ': r) a Source #

Reinterpreting version of pureMethodology.

Since: 0.1.7.0

bindMethodology :: forall f b c r a. (Members '[Methodology b (f c)] r, Traversable f, Monad f) => Sem (Methodology (f b) (f c) ': r) a -> Sem r a Source #

Run a Methodology (f b) (f c) by way of a Methodology b (f c). Note that f must be both Traversable and Monad.

Since: 0.1.2.0

bindMethodology' :: forall f b c r a. (Traversable f, Monad f) => Sem (Methodology (f b) (f c) ': r) a -> Sem (Methodology b (f c) ': r) a Source #

Reinterpreting version of bindMethodology.

Since: 0.1.6.0

traverseMethodology :: forall t f b c r a. (Members '[Methodology b (f c)] r, Traversable t, Applicative f) => Sem (Methodology (t b) (f (t c)) ': r) a -> Sem r a Source #

Run a Methodology (t b) (f (t b)) by way of a Methodology b (f c). Note that t must be Traversable and f must be Applicative.

Since: 0.1.2.0

traverseMethodology' :: forall t f b c r a. (Traversable t, Applicative f) => Sem (Methodology (t b) (f (t c)) ': r) a -> Sem (Methodology b (f c) ': r) a Source #

Reinterpreting version of traverseMethodology.

Since: 0.1.6.0

mconcatMethodology :: forall f b c r a. (Members '[Methodology b c] r, Monoid c, Traversable f) => Sem (Methodology (f b) c ': r) a -> Sem r a Source #

Run a Methodology concatenating the results as a monoid.

Since: 0.1.5.0

mconcatMethodology' :: forall f b c r a. (Monoid c, Traversable f) => Sem (Methodology (f b) c ': r) a -> Sem (Methodology b c ': r) a Source #

Reinterpreting version of mconcatMethodology.

Since: 0.1.6.0

Other Effects

teeMethodologyOutput :: forall b c r a. Members '[Output c, Methodology b c] r => Sem r a -> Sem r a Source #

Tee the output of a Methodology, introducing a new Output effect to be handled.

Since: 0.1.0.0

plugMethodologyInput :: forall b c d r a. Members '[Input b, Methodology (b, c) d] r => Sem (Methodology c d ': r) a -> Sem r a Source #

Make a Methodology depend on an additional input, introducing a new Input effect to be handled.

Since: 0.1.0.0

runMethodologyAsKVStore :: forall k v r a. Members '[KVStore k v] r => Sem (Methodology k (Maybe v) ': r) a -> Sem r a Source #

Run a Methodology as a KVStore, using the input as a key and the output as the value.

Since: 0.1.0.0

runMethodologyAsKVStoreWithDefault Source #

Arguments

:: forall k v r a. Members '[KVStore k v] r 
=> v

A default value v.

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

Run a Methodology as a KVStore, with a default value for lookup failure.

Since: 0.1.0.0

runMethodologyMappendPure :: forall b c r a. (Monoid c, Members '[Methodology b c] r) => (b -> c) -> Sem r a -> Sem r a Source #

Run a Methodology targetting a Monoid without consuming it, pure version. This should probably be considered an anti-pattern, and it's probably better to decompose the inputs fully, but is otherwise sound.

Since: 0.1.8.0

runMethodologyMappendSem :: forall b c r a. (Monoid c, Members '[Methodology b c] r) => (b -> Sem r c) -> Sem r a -> Sem r a Source #

Run a Methodology targetting a Monoid without consuming it, Sem version. This should probably be considered an anti-pattern, and it's probably better to decompose the inputs fully, but is otherwise sound.

Since: 0.1.8.0

Tracing

traceMethodologyStart Source #

Arguments

:: forall b c r a. Members '[Methodology b c, Trace] r 
=> (b -> String)

A function from the input type b to a String.

-> Sem r a 
-> Sem r a 

Trace a String based on the input to a Methodology.

Since: 0.1.3.0

traceMethodologyEnd Source #

Arguments

:: forall b c r a. Members '[Methodology b c, Trace] r 
=> (c -> String)

A function from the output type c to a String.

-> Sem r a 
-> Sem r a 

Trace a String based on the output to a Methodology.

Since: 0.1.3.0

traceMethodologyAround Source #

Arguments

:: forall b c r a. Members '[Methodology b c, Trace] r 
=> (b -> String)

A function from the input type b to a String.

-> (c -> String)

A function from the output type c to a String.

-> Sem r a 
-> Sem r a 

Trace both the start and the end of a Methodology.

Since: 0.1.3.0