polysemy-methodology 0.1.8.0 → 0.2.0.0
raw patch · 3 files changed
+360/−325 lines, 3 filesdep +polysemy-kvstoredep +polysemy-severaldep −co-log-polysemydep −polysemy-zoodep ~basedep ~polysemydep ~polysemy-pluginPVP ok
version bump matches the API change (PVP)
Dependencies added: polysemy-kvstore, polysemy-several
Dependencies removed: co-log-polysemy, polysemy-zoo
Dependency ranges changed: base, polysemy, polysemy-plugin
API changes (from Hackage documentation)
- Polysemy.Methodology: logMethodologyAround :: forall b c p q r a. Members '[Methodology b c, Log p, Log q] r => (b -> p) -> (c -> q) -> Sem r a -> Sem r a
- Polysemy.Methodology: logMethodologyEnd :: forall b c q r a. Members '[Methodology b c, Log q] r => (c -> q) -> Sem r a -> Sem r a
- Polysemy.Methodology: logMethodologyStart :: forall b c p r a. Members '[Methodology b c, Log p] r => (b -> p) -> Sem r a -> Sem r a
- Polysemy.Methodology: process :: forall b_ab9B c_ab9C r_acrp. MemberWithError (Methodology b_ab9B c_ab9C) r_acrp => b_ab9B -> Sem r_acrp c_ab9C
+ Polysemy.Methodology: process :: forall b_aaD9 c_aaDa r_abUX. MemberWithError (Methodology b_aaD9 c_aaDa) r_abUX => b_aaD9 -> Sem r_abUX c_aaDa
Files
- ChangeLog.md +5/−0
- polysemy-methodology.cabal +7/−7
- src/Polysemy/Methodology.hs +348/−318
ChangeLog.md view
@@ -1,5 +1,10 @@ # Changelog for polysemy-methodology +## v0.2.0.0++* Drop dependency on polysemy-zoo and replace with polysemy-several.+* Drop logging functions and move to polysemy-methodology-co-log+ ## v0.1.8.0 * Add `runMethodologyMappendPure` and `runMethodologyMappendSem`.
polysemy-methodology.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.2.+-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack name: polysemy-methodology-version: 0.1.8.0+version: 0.2.0.0 synopsis: Domain modelling algebra for polysemy category: Polysemy author: Daniel Firth@@ -31,9 +31,9 @@ src ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints build-depends:- base >=4.7 && <5- , co-log-polysemy- , polysemy >=1.3.0.0 && <1.5- , polysemy-plugin- , polysemy-zoo >=0.7.0.1 && <0.8+ base >=4.7 && <4.16+ , polysemy >=1.3.0.0 && <1.7+ , polysemy-kvstore >=0.1.2.0 && <0.2+ , polysemy-plugin >=0.3 && <0.5+ , polysemy-several ==0.1.* default-language: Haskell2010
src/Polysemy/Methodology.hs view
@@ -1,88 +1,83 @@-{- |- Module : Polysemy.Methodology- License : MIT- Stability : experimental--Domain modelling algebra for polysemy.--} {-# LANGUAGE AllowAmbiguousTypes #-}-{-# LANGUAGE BlockArguments #-}-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE LambdaCase #-}-{-# LANGUAGE GADTs #-}-{-# LANGUAGE PolyKinds #-}+{-# LANGUAGE BlockArguments #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TemplateHaskell #-}-{-# LANGUAGE TypeApplications #-}-{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -fplugin=Polysemy.Plugin #-}-module Polysemy.Methodology (--- * Definition- Methodology(..)-, process --- * Eliminators-, runMethodologyPure-, runMethodologySem+-- |+-- Module : Polysemy.Methodology+-- License : MIT+-- Stability : experimental+--+-- Domain modelling algebra for polysemy.+module Polysemy.Methodology+ ( -- * Definition+ Methodology (..),+ process, --- * Decomposition-, cutMethodology-, cutMethodology'-, cutMethodology3-, cutMethodology3'-, divideMethodology-, divideMethodology'-, decideMethodology-, decideMethodology'-, decomposeMethodology-, decomposeMethodology'-, decomposeMethodology3-, separateMethodologyInitial-, endMethodologyInitial-, separateMethodologyTerminal-, endMethodologyTerminal+ -- * Eliminators+ runMethodologyPure,+ runMethodologySem, --- * Simplifcation-, fmapMethodology-, fmapMethodology'-, fmap2Methodology-, fmap2Methodology'-, pureMethodology-, pureMethodology'-, bindMethodology-, bindMethodology'-, traverseMethodology-, traverseMethodology'-, mconcatMethodology-, mconcatMethodology'+ -- * Decomposition+ cutMethodology,+ cutMethodology',+ cutMethodology3,+ cutMethodology3',+ divideMethodology,+ divideMethodology',+ decideMethodology,+ decideMethodology',+ decomposeMethodology,+ decomposeMethodology',+ decomposeMethodology3,+ separateMethodologyInitial,+ endMethodologyInitial,+ separateMethodologyTerminal,+ endMethodologyTerminal, --- * Other Effects-, teeMethodologyOutput-, plugMethodologyInput-, runMethodologyAsKVStore-, runMethodologyAsKVStoreWithDefault-, runMethodologyMappendPure-, runMethodologyMappendSem+ -- * Simplifcation+ fmapMethodology,+ fmapMethodology',+ fmap2Methodology,+ fmap2Methodology',+ pureMethodology,+ pureMethodology',+ bindMethodology,+ bindMethodology',+ traverseMethodology,+ traverseMethodology',+ mconcatMethodology,+ mconcatMethodology', --- * Tracing-, traceMethodologyStart-, traceMethodologyEnd-, traceMethodologyAround+ -- * Other Effects+ teeMethodologyOutput,+ plugMethodologyInput,+ runMethodologyAsKVStore,+ runMethodologyAsKVStoreWithDefault,+ runMethodologyMappendPure,+ runMethodologyMappendSem, --- * Logging-, logMethodologyStart-, logMethodologyEnd-, logMethodologyAround-) where+ -- * Tracing+ traceMethodologyStart,+ traceMethodologyEnd,+ traceMethodologyAround,+ )+where import Control.Applicative import Control.Arrow import Control.Monad-import Colog.Polysemy as C import Polysemy-import Polysemy.KVStore import Polysemy.Input+import Polysemy.KVStore import Polysemy.Output import Polysemy.Several import Polysemy.Trace@@ -96,12 +91,12 @@ -- | Run a `Methodology` using a pure function. -- -- @since 0.1.0.0-runMethodologyPure- :: forall b c r a.- (b -> c)- -- ^ A function from b to c.- -> Sem (Methodology b c ': r) a- -> Sem r a+runMethodologyPure ::+ forall b c r a.+ -- | A function from b to c.+ (b -> c) ->+ Sem (Methodology b c ': r) a ->+ Sem r a runMethodologyPure f = interpret \case Process b -> return $ f b {-# INLINE runMethodologyPure #-}@@ -109,11 +104,12 @@ -- | Run a `Methodology' using a monadic function with effects in `r`. -- -- @since 0.1.0.0-runMethodologySem :: 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+runMethodologySem ::+ forall b c r a.+ -- | A monadic function from b to c using effects in r.+ (b -> Sem r c) ->+ Sem (Methodology b c ': r) a ->+ Sem r a runMethodologySem f = interpret \case Process b -> f b {-# INLINE runMethodologySem #-}@@ -121,12 +117,16 @@ -- | Cut a `Methodology` into two pieces at a midpoint. -- -- @since 0.1.0.0-cutMethodology :: 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+cutMethodology ::+ forall b c d r a.+ Members+ '[ Methodology b c,+ Methodology c d+ ]+ r =>+ -- | Methodology effect to decompose.+ Sem (Methodology b d ': r) a ->+ Sem r a cutMethodology = interpret \case Process b -> process @b @c b >>= process @c @d {-# INLINE cutMethodology #-}@@ -134,10 +134,11 @@ -- | Reinterpreting version of `cutMethodology`. -- -- @since 0.1.6.0-cutMethodology' :: 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+cutMethodology' ::+ forall b c d r a.+ -- | Methodology effect to decompose.+ Sem (Methodology b d ': r) a ->+ Sem (Methodology b c ': Methodology c d ': r) a cutMethodology' = reinterpret2 \case Process b -> process @b @c b >>= raise . process @c @d {-# INLINE cutMethodology' #-}@@ -145,13 +146,17 @@ -- | Cut a `Methodology` into three pieces using two cuts. -- -- @since 0.1.0.0-cutMethodology3 :: 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+cutMethodology3 ::+ forall b c d e r a.+ Members+ '[ Methodology b c,+ Methodology c d,+ Methodology d e+ ]+ r =>+ -- | Methodology effect to decompose.+ Sem (Methodology b e ': r) a ->+ Sem r a cutMethodology3 = interpret \case Process b -> process @b @c b >>= process @c @d >>= process @d @e {-# INLINE cutMethodology3 #-}@@ -159,10 +164,11 @@ -- | Reinterpreting version of `cutMethodology`. -- -- @since 0.1.6.0-cutMethodology3' :: 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+cutMethodology3' ::+ forall b c d e r a.+ -- | Methodology effect to decompose.+ Sem (Methodology b d ': r) a ->+ Sem (Methodology b c ': Methodology c d ': Methodology d e ': r) a cutMethodology3' = reinterpret3 \case Process b -> process @b @c b >>= raise . process @c @d {-# INLINE cutMethodology3' #-}@@ -170,16 +176,20 @@ -- | 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.- 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+divideMethodology ::+ forall b c c' d r a.+ Members+ '[ Methodology b c,+ Methodology b c',+ Methodology (c, c') d+ ]+ r =>+ -- | Methodology effect to decompose.+ Sem (Methodology b d ': r) a ->+ Sem r a divideMethodology = interpret \case Process b -> do- c <- process @b @c b+ c <- process @b @c b c' <- process @b @c' b process @(c, c') @d (c, c') {-# INLINE divideMethodology #-}@@ -187,12 +197,13 @@ -- | Reinterpreting version of `divideMethodology`. -- -- @since 0.1.6.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+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 divideMethodology' = reinterpret3 \case Process b -> do- c <- process @b @c b+ c <- process @b @c b c' <- raise $ process @b @c' b raise $ raise $ process @(c, c') @d (c, c') {-# INLINE divideMethodology' #-}@@ -200,44 +211,52 @@ -- | Decide between two `Methodology`s using a `Methodology` that computes an `Either`. -- -- @since 0.1.0.0-decideMethodology :: 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+decideMethodology ::+ forall b c c' d r a.+ Members+ '[ Methodology b (Either c c'),+ Methodology c d,+ Methodology c' d+ ]+ r =>+ -- | `Methodology effect to decompose.+ Sem (Methodology b d ': r) a ->+ Sem r a decideMethodology = interpret \case Process b -> do k <- process @b @(Either c c') b case k of- Left c -> process @c @d c+ Left c -> process @c @d c Right c' -> process @c' @d c' {-# INLINE decideMethodology #-} -- | Reinterpreting version of `decideMethodology`. -- -- @since 0.1.6.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+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 decideMethodology' = reinterpret3 \case Process b -> do k <- process @b @(Either c c') b case k of- Left c -> raise $ process @c @d c+ Left c -> raise $ process @c @d c Right c' -> raise $ raise $ process @c' @d c' {-# INLINE decideMethodology' #-} -- | Tee the output of a `Methodology`, introducing a new `Output` effect to be handled. -- -- @since 0.1.0.0-teeMethodologyOutput :: forall b c r a.- Members '[ Output c- , Methodology b c] r- => Sem r a- -> Sem r a+teeMethodologyOutput ::+ forall b c r a.+ Members+ '[ Output c,+ Methodology b c+ ]+ r =>+ Sem r a ->+ Sem r a teeMethodologyOutput = intercept \case Process b -> do k <- process @b @c b@@ -248,10 +267,11 @@ -- | Make a `Methodology` depend on an additional input, introducing a new `Input` 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+plugMethodologyInput ::+ forall b c d r a.+ Members '[Input b, Methodology (b, c) d] r =>+ Sem (Methodology c d ': r) a ->+ Sem r a plugMethodologyInput = interpret \case Process b -> do k <- input @b@@ -261,10 +281,11 @@ -- | Run a `Methodology` as a `KVStore`, using the input as a key and the output as the value. -- -- @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+runMethodologyAsKVStore ::+ forall k v r a.+ Members '[KVStore k v] r =>+ Sem (Methodology k (Maybe v) ': r) a ->+ Sem r a runMethodologyAsKVStore = interpret \case Process k -> lookupKV k {-# INLINE runMethodologyAsKVStore #-}@@ -272,12 +293,13 @@ -- | Run a `Methodology` as a `KVStore`, with a default value for lookup failure. -- -- @since 0.1.0.0-runMethodologyAsKVStoreWithDefault :: forall k v r a.- Members '[KVStore k v] r- => v- -- ^ A default value v.- -> Sem (Methodology k v ': r) a- -> Sem r a+runMethodologyAsKVStoreWithDefault ::+ forall k v r a.+ Members '[KVStore k v] r =>+ -- | A default value v.+ v ->+ Sem (Methodology k v ': r) a ->+ Sem r a runMethodologyAsKVStoreWithDefault d = interpret \case Process k -> do z <- lookupKV k@@ -290,11 +312,14 @@ -- anti-pattern, and it's probably better to decompose the inputs fully, but is otherwise sound. -- -- @since 0.1.8.0-runMethodologyMappendPure :: forall b c r a.- (Monoid c,- Members '[Methodology b c] r)- => (b -> c)- -> Sem r a -> Sem r a+runMethodologyMappendPure ::+ forall b c r a.+ ( Monoid c,+ Members '[Methodology b c] r+ ) =>+ (b -> c) ->+ Sem r a ->+ Sem r a runMethodologyMappendPure f = intercept \case Process b -> (f b <>) <$> process @b @c b {-# INLINE runMethodologyMappendPure #-}@@ -303,11 +328,14 @@ -- 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+runMethodologyMappendSem ::+ forall b c r a.+ ( Monoid c,+ Members '[Methodology b c] r+ ) =>+ (b -> Sem r c) ->+ Sem r a ->+ Sem r a runMethodologyMappendSem f = intercept \case Process b -> liftA2 (<>) (f b) (process @b @c b) {-# INLINE runMethodologyMappendSem #-}@@ -315,55 +343,69 @@ -- | 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.- Members ' [Methodology b (HList f)- , Methodology (HList f) c] r- => Sem (Methodology b c ': r) a- -> Sem r a+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 decomposeMethodology = cutMethodology @b @(HList f) @c {-# INLINE decomposeMethodology #-} -- | Reinterpreting version of `decomposeMethodology`. -- -- @since 0.1.6.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+decomposeMethodology' ::+ forall b f c r a.+ Sem (Methodology b c ': r) a ->+ Sem (Methodology b (HList f) ': Methodology (HList f) c ': r) a decomposeMethodology' = cutMethodology' @b @(HList f) @c {-# INLINE decomposeMethodology' #-} -- | Decompose a `Methodology` into several components over three sections with two cuts. -- -- @since 0.1.0.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+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 decomposeMethodology3 = cutMethodology3 @b @(HList f) @(HList g) @c {-# INLINE decomposeMethodology3 #-} -- | Factor a `Methodology` decomposed over an `HList` in the result by a `Methodology` to the first variable. -- -- @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+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 separateMethodologyInitial = interpret \case Process b -> do- k <- process @b @x b- k' <- process @b @(HList xs) b+ k <- process @b @x b+ k' <- process @b @(HList xs) b return $ k ::: k' {-# INLINE separateMethodologyInitial #-} -- | Finish an `HList` separated `Methodology` by consuming it for no effect. -- -- @since 0.1.0.0-endMethodologyInitial :: Sem (Methodology b (HList '[]) ': r) a- -> Sem r a+endMethodologyInitial ::+ Sem (Methodology b (HList '[]) ': r) a ->+ Sem r a endMethodologyInitial = interpret \case Process _ -> return HNil {-# INLINE endMethodologyInitial #-}@@ -372,25 +414,31 @@ -- `Methodology` from the first variable. Assumes the result is a `Monoid`. -- -- @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+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 separateMethodologyTerminal = interpret \case Process (b ::: bs) -> do- k <- process @x @c b- k' <- process @(HList xs) @c bs+ k <- process @x @c b+ k' <- process @(HList xs) @c bs return $ k <> k' {-# INLINE separateMethodologyTerminal #-} -- | Finalise an `HList` separated `Methodology` in the source by returning the `Monoid` unit. -- -- @since 0.1.0.0-endMethodologyTerminal :: Monoid c- => Sem (Methodology (HList '[]) c ': r) a- -> Sem r a+endMethodologyTerminal ::+ Monoid c =>+ Sem (Methodology (HList '[]) c ': r) a ->+ Sem r a endMethodologyTerminal = interpret \case Process _ -> return mempty {-# INLINE endMethodologyTerminal #-}@@ -399,11 +447,13 @@ -- `f` must be `Traversable`. -- -- @since 0.1.2.0-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+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 fmapMethodology = interpret \case Process b -> traverse (process @b @c) b {-# INLINE fmapMethodology #-}@@ -411,10 +461,11 @@ -- | Reinterpreting version of `fmapMethodology`. -- -- @since 0.1.6.0-fmapMethodology' :: forall f b c r a.- Traversable f- => Sem (Methodology (f b) (f c) ': r) a- -> Sem (Methodology b c ': r) a+fmapMethodology' ::+ forall f b c r a.+ Traversable f =>+ Sem (Methodology (f b) (f c) ': r) a ->+ Sem (Methodology b c ': r) a fmapMethodology' = raiseUnder >>> fmapMethodology {-# INLINE fmapMethodology' #-} @@ -422,31 +473,36 @@ -- `f` and `g` must be `Traversable`. -- -- @since 0.1.2.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+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 fmap2Methodology = fmapMethodology' @f @(g b) @(g c) >>> fmapMethodology @g @b @c {-# INLINE fmap2Methodology #-} --- | Reinterpreting version of `fmapMethodology`.+-- | Reinterpreting version of `fmap2Methodology`. -- -- @since 0.1.6.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+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 fmap2Methodology' = raiseUnder >>> fmap2Methodology {-# INLINE fmap2Methodology' #-} -- | 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.- (Members '[Methodology b c] r, Applicative f)- => Sem (Methodology b (f c) ': r) a- -> Sem r a+pureMethodology ::+ forall f b c r a.+ (Members '[Methodology b c] r, Applicative f) =>+ Sem (Methodology b (f c) ': r) a ->+ Sem r a pureMethodology = interpret \case Process b -> pure <$> process @b @c b {-# INLINE pureMethodology #-}@@ -454,9 +510,11 @@ -- | Reinterpreting version of `pureMethodology`. -- -- @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+pureMethodology' ::+ forall f b c r a.+ Applicative f =>+ Sem (Methodology b (f c) ': r) a ->+ Sem (Methodology b c ': r) a pureMethodology' = raiseUnder >>> pureMethodology {-# INLINE pureMethodology' #-} @@ -464,11 +522,14 @@ -- `f` must be both `Traversable` and `Monad`. -- -- @since 0.1.2.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+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 bindMethodology = interpret \case Process b -> join <$> traverse (process @b @(f c)) b {-# INLINE bindMethodology #-}@@ -476,10 +537,11 @@ -- | Reinterpreting version of `bindMethodology`. -- -- @since 0.1.6.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+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 bindMethodology' = raiseUnder >>> bindMethodology {-# INLINE bindMethodology' #-} @@ -487,11 +549,14 @@ -- `t` must be `Traversable` and `f` must be `Applicative`. -- -- @since 0.1.2.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+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 traverseMethodology = interpret \case Process b -> sequenceA <$> traverse (process @b @(f c)) b {-# INLINE traverseMethodology #-}@@ -499,21 +564,25 @@ -- | Reinterpreting version of `traverseMethodology`. -- -- @since 0.1.6.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+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 traverseMethodology' = raiseUnder >>> traverseMethodology {-# INLINE traverseMethodology' #-} -- | Run a `Methodology` concatenating the results as a monoid. -- -- @since 0.1.5.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+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 mconcatMethodology = interpret \case Process b -> traverse (process @b @c) b >>= return . foldr (<>) mempty {-# INLINE mconcatMethodology #-}@@ -521,23 +590,28 @@ -- | Reinterpreting version of `mconcatMethodology`. -- -- @since 0.1.6.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+mconcatMethodology' ::+ forall f b c r a.+ (Monoid c, Traversable f) =>+ Sem (Methodology (f b) c ': r) a ->+ Sem (Methodology b c ': r) a mconcatMethodology' = raiseUnder >>> mconcatMethodology {-# INLINE mconcatMethodology' #-} -- | `Trace` a `String` based on the input to a `Methodology`. -- -- @since 0.1.3.0-traceMethodologyStart :: 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+traceMethodologyStart ::+ forall b c r a.+ Members+ '[ Methodology b c,+ Trace+ ]+ r =>+ -- | A function from the input type b to a `String`.+ (b -> String) ->+ Sem r a ->+ Sem r a traceMethodologyStart f = intercept \case Process b -> trace (f b) >> process @b @c b {-# INLINE traceMethodologyStart #-}@@ -545,13 +619,17 @@ -- | `Trace` a `String` based on the output to a `Methodology`. -- -- @since 0.1.3.0-traceMethodologyEnd :: 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+traceMethodologyEnd ::+ forall b c r a.+ Members+ '[ Methodology b c,+ Trace+ ]+ r =>+ -- | A function from the output type c to a `String`.+ (c -> String) ->+ Sem r a ->+ Sem r a traceMethodologyEnd f = intercept \case Process b -> do c <- process @b @c b@@ -562,15 +640,19 @@ -- | `Trace` both the start and the end of a `Methodology`. -- -- @since 0.1.3.0-traceMethodologyAround :: 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+traceMethodologyAround ::+ forall b c r a.+ Members+ '[ Methodology b c,+ Trace+ ]+ r =>+ -- | A function from the input type b to a `String`.+ (b -> String) ->+ -- | A function from the output type c to a `String`.+ (c -> String) ->+ Sem r a ->+ Sem r a traceMethodologyAround f g = intercept \case Process b -> do trace $ f b@@ -578,55 +660,3 @@ trace $ g c return c {-# INLINE traceMethodologyAround #-}---- | `Log` a type based on the input to a `Methodology`.------ @since 0.1.4.0-logMethodologyStart :: forall b c p r a.- Members '[Methodology b c,- Log p] r- => (b -> p)- -- ^ A function from the input type b to an event type p.- -> Sem r a- -> Sem r a-logMethodologyStart f = intercept \case- Process b -> C.log (f b) >> process @b @c b-{-# INLINE logMethodologyStart #-}---- | `Log` a type based on the output to a `Methodology`.------ @since 0.1.4.0-logMethodologyEnd :: forall b c q r a.- Members '[Methodology b c,- Log q] r- => (c -> q)- -- ^ A function from the input type c to an event type q.- -> Sem r a- -> Sem r a-logMethodologyEnd f = intercept \case- Process b -> do- c <- process @b @c b- C.log $ f c- return c-{-# INLINE logMethodologyEnd #-}---- | `Log` both the start and the end of a `Methodology`.------ @since 0.1.4.0-logMethodologyAround :: forall b c p q r a.- Members '[ Methodology b c- , Log p- , Log q] r- => (b -> p)- -- ^ A function from the input type b to an event type p.- -> (c -> q)- -- ^ A function from the output type b to an event type q,- -> Sem r a- -> Sem r a-logMethodologyAround f g = intercept \case- Process b -> do- C.log $ f b- c <- process @b @c b- C.log $ g c- return c-{-# INLINE logMethodologyAround #-}