Skip to content

Commit

Permalink
Fix export
Browse files Browse the repository at this point in the history
  • Loading branch information
soareschen committed Mar 31, 2019
1 parent 40d4736 commit 82aca24
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 10 deletions.
4 changes: 4 additions & 0 deletions Makefile
Expand Up @@ -17,6 +17,10 @@ shell:
external-shell:
nix-shell nix/external.nix

clean:
nix-shell --pure nix/shell.nix --run \
"make -f make/nix.mk clean"

hoogle:
nix-shell --pure nix/external.nix --run \
"hoogle server --local --host 0.0.0.0 -p 8333"
Expand Down
19 changes: 14 additions & 5 deletions README.md
Expand Up @@ -272,19 +272,25 @@ already a well tested and high performance implementation for the state
effect, which is the `StateT` monad transformer provided by `mtl`, so why
not use that instead?

In fact `implicit-effects` provides the `StateOps` instance for any
`StateT eff` in `Control.Effect.Implicit.Transform.State`:
In fact `implicit-effects` provides the `stateTOps` instance for any
`StateT eff`:

```haskell
-- module Control.Effect.Implicit.Transform.State

stateTOps
:: forall eff s . (Effect eff)
=> StateOps s (StateT s eff)
:: forall eff s
. (Effect eff, MonadState s eff)
=> StateOps s eff
stateTOps = StateOps {
getOp = get,
putOp = put
}
```

`stateTOps` can provide state operation on any `MonadState` instance by just
delegating to `mtl`.

...

## To Be Continued..
Expand All @@ -293,4 +299,7 @@ I am still working on writing the documentation and tutorial for
`implicit-effects`. Thank you for taking the time to read until here.
In the meanwhile, you can refer to the
[Haddock documentation](https://maybevoid.com/implicit-effects-haddock/)
for `implicit-effects` to learn more.
for `implicit-effects` to learn more.

You can also look at the [effect operation unit tests](src/test/Effect/Test/Ops)
which has some example use of `implicit-effects`.
3 changes: 3 additions & 0 deletions make/nix.mk
Expand Up @@ -4,6 +4,9 @@ hpack:
sync: hpack
cabal2nix . > default.nix

clean:
cabal new-clean

repl: hpack
cabal new-repl --write-ghc-environment-files never lib:implicit-effects

Expand Down
1 change: 1 addition & 0 deletions src/benchmark/Benchmark/State/FreePipeline.hs
Expand Up @@ -8,6 +8,7 @@ import Control.Monad.Trans.Reader (ReaderT)
import Control.Effect.Implicit
import Control.Effect.Implicit.Ops.Env
import Control.Effect.Implicit.Ops.State
import Control.Effect.Implicit.Transform.Reader

import Benchmark.State.Base

Expand Down
2 changes: 2 additions & 0 deletions src/benchmark/Benchmark/State/StateEffToEnvEff.hs
Expand Up @@ -15,6 +15,8 @@ import Control.Monad.Trans.State.Strict (StateT, evalStateT)
import Control.Effect.Implicit
import Control.Effect.Implicit.Ops.Env
import Control.Effect.Implicit.Ops.State
import Control.Effect.Implicit.Transform.State
import Control.Effect.Implicit.Transform.Reader

import Benchmark.State.Base

Expand Down
2 changes: 2 additions & 0 deletions src/benchmark/Benchmark/State/StateEffToReaderT.hs
Expand Up @@ -11,6 +11,8 @@ import qualified Control.Monad.Trans.Reader as RT

import Control.Effect.Implicit
import Control.Effect.Implicit.Ops.State
import Control.Effect.Implicit.Transform.State
import Control.Effect.Implicit.Transform.Reader

import Benchmark.State.Base

Expand Down
2 changes: 2 additions & 0 deletions src/benchmark/Benchmark/State/StateTHandler.hs
Expand Up @@ -5,6 +5,8 @@ where
import Control.Monad.Trans.State.Strict (StateT)

import Control.Effect.Implicit
import Control.Effect.Implicit.Transform.State

import Benchmark.State.Base

stateHComp1
Expand Down
2 changes: 2 additions & 0 deletions src/benchmark/Benchmark/State/StateTPipeline.hs
Expand Up @@ -13,6 +13,8 @@ import Control.Monad.Trans.Reader (ReaderT)

import Control.Effect.Implicit
import Control.Effect.Implicit.Ops.Env
import Control.Effect.Implicit.Transform.State
import Control.Effect.Implicit.Transform.Reader

import Benchmark.State.Base

Expand Down
2 changes: 2 additions & 0 deletions src/benchmark/Benchmark/State/WithStateT.hs
Expand Up @@ -9,6 +9,8 @@ import Control.Monad.Trans.State.Strict (StateT, evalStateT)
import qualified Control.Monad.Trans.Reader as RT

import Control.Effect.Implicit
import Control.Effect.Implicit.Transform.State

import Benchmark.State.Base

withStateOpsComp :: forall eff . (Effect eff)
Expand Down
12 changes: 7 additions & 5 deletions src/lib/Control/Effect/Implicit/Transform/State.hs
Expand Up @@ -2,7 +2,8 @@
module Control.Effect.Implicit.Transform.State
where

import Control.Monad.Trans.State.Strict
import Control.Monad.State.Class (MonadState (..))
import Control.Monad.Trans.State.Strict (StateT, evalStateT)

import Control.Monad.Trans.Class
(MonadTrans (..))
Expand All @@ -20,17 +21,18 @@ liftStateT
liftStateT = mkLiftEff lift

stateTOps
:: forall eff s . (Effect eff)
=> StateOps s (StateT s eff)
:: forall eff s
. (Effect eff, MonadState s eff)
=> StateOps s eff
stateTOps = StateOps {
getOp = get,
putOp = put
}

stateTHandler
:: forall eff s .
(Effect eff)
=> Handler NoEff (StateEff s) (StateT s eff)
(Effect eff, MonadState s eff)
=> Handler NoEff (StateEff s) eff
stateTHandler = mkHandler $
\lifter -> applyEffmap lifter stateTOps

Expand Down

0 comments on commit 82aca24

Please sign in to comment.