-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathHello.purs
More file actions
27 lines (22 loc) · 931 Bytes
/
Hello.purs
File metadata and controls
27 lines (22 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module Test.Hello where
import Prelude
import Concur.Core (Widget)
import Concur.React (HTML, toReactClass)
import Concur.React.DOM as D
import Concur.React.Props as P
import Control.Monad.Rec.Class (forever)
import Control.Monad.State.Class (get, put)
import Control.Monad.State.Trans (StateT, runStateT)
import React (ReactClass)
helloWidget :: forall a. Widget HTML a
helloWidget = do
void $ runStateT helloWidgetS 0
D.text "Actually this will never be reached, but the compiler is not smart enough to deduce that"
helloWidgetS :: forall a. StateT Int (Widget HTML) a
helloWidgetS = forever do
count <- get
void $ D.div' [ D.button [P.onClick] [D.text ("For the " <> show count <> " time, hello sailor!")] ]
put (count + 1)
-- This widget class is imported directly from a JS component. See JSInterface.js
helloWidgetClass :: ReactClass {}
helloWidgetClass = toReactClass "HelloWidget" mempty (const helloWidget)