Skip to content

Instantly share code, notes, and snippets.

@jfdm
Last active October 13, 2015 13:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jfdm/3e20fca2382bbe0675d3 to your computer and use it in GitHub Desktop.
Save jfdm/3e20fca2382bbe0675d3 to your computer and use it in GitHub Desktop.
module FoobarE
import Effects
import Effect.State
import Effect.StdIO
namespace Lib
MyLib : Type -> Type
MyLib rTy = Eff rTy ['libstate ::: STATE (List Nat), STDIO]
register : Nat -> MyLib ()
register x = 'libstate :- update (x::)
count : MyLib Nat
count = pure (length !('libstate :- get))
namespace User
User : Type -> Type
User rTy = Eff rTy [ 'libstate ::: STATE (List Nat)
, 'mystate ::: STATE (List Nat)
, STDIO]
wipe : User ()
wipe = 'libstate :- put Nil
myProg : User ()
myProg = do
register 1
register 2
printLn !count
wipe
register 3
register 4
printLn !count
namespace Main
main : IO ()
main = run myProg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment