Skip to content

Instantly share code, notes, and snippets.

@natefaubion
Created July 31, 2020 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natefaubion/03b3f464c7a1da986848f5ce80807e9e to your computer and use it in GitHub Desktop.
Save natefaubion/03b3f464c7a1da986848f5ce80807e9e to your computer and use it in GitHub Desktop.
Counter
module Main where
import Prelude
import Effect
import Effect.Console
import Effect.Ref as Ref
import TryPureScript
makeCounter :: Effect (Effect Int)
makeCounter = do
ref <- Ref.new 0
pure $ Ref.modify (add 1) ref
main :: Effect Unit
main = render =<< withConsole do
count <- makeCounter
n1 <- count
n2 <- count
n3 <- count
logShow [ n1, n2, n3 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment