Last active
June 6, 2020 17:50
-
-
Save ajnsit/223bab27ff20c67eb87ec60203e9d4dd to your computer and use it in GitHub Desktop.
Try-Purescript, simple up/down counter example with Concur
This file contains hidden or 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 (Effect) | |
import Concur.Core (Widget) | |
import Concur.React (HTML) | |
import Concur.React.DOM as D | |
import Concur.React.Props as P | |
import Concur.React.Run (runWidgetInDom) | |
counterWidget :: forall a. Int -> Widget HTML a | |
counterWidget count = do | |
n <- D.div' | |
[ D.p' [D.text ("State: " <> show count)] | |
, D.button [P.onClick] [D.text "Increment"] $> count+1 | |
, D.button [P.onClick] [D.text "Decrement"] $> count-1 | |
] | |
counterWidget n | |
main :: Effect Unit | |
main = runWidgetInDom "main" (counterWidget 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment