galaxy-sixth-sensey - Run a program of Eff in pure contexts
2018/02/18
Run a program of Eff in pure contexts

In a situation, I have a program (Eff) with a STATE effect, and the program is pure.

It can be run in a pure context like below 😂

import Control.Monad.Identity
import Effect.State
import Effects

main : IO ()
main = do
  let Id (_ ** [s]) = runEnv {m=Identity} [default] $ update (+1)
  printLn s
-- {output}
-- 1

PS

I took a Pull Request, Above code can be written as below (no Identity is needed), if the PR is approved 🐕

import Effect.State
import Effects

-- runPureEnv : (env : Env Basics.id xs) -> (prog : EffM Basics.id a xs xs') -> (x : a ** Env Basics.id (xs' x))
-- runPureEnv env prog = eff env prog (\r, env => (r ** env))

main : IO ()
main = do
  let (_ ** [s]) = runPureEnv [default] $ update (+1)
  printLn s

この記事はこちらから修正リクエストを送ることができます。
Run a program of Eff in pure contexts - github
ゴミ箱ボタンの左にある、鉛筆ボタンを押してね!