Created
July 31, 2020 20:41
-
-
Save natefaubion/03b3f464c7a1da986848f5ce80807e9e to your computer and use it in GitHub Desktop.
Counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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