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

筆者プロフィール

my-latest-logo

aiya000(あいや)

せつラボ 〜圏論の基本〜」 「せつラボ2~雲と天使と関手圏~」 「矢澤にこ先輩といっしょに代数!」を書いています!

強い静的型付けとテストを用いて、バグを防ぐのが好き。Haskell・TypeScript。