Update for latest Halogen and PureScript 0.9.1
parent
960f2f1128
commit
888c339023
|
@ -1,5 +1,7 @@
|
|||
# purescript-halogen-template
|
||||
|
||||
[![Dependency Status](https://www.versioneye.com/user/projects/576ebffc6f9c59003d351060/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/576ebffc6f9c59003d351060)
|
||||
|
||||
This is a template for starting a fresh project using the [purescript-halogen](https://github.com/slamdata/purescript-halogen) library for declarative user interfaces.
|
||||
|
||||
## Prerequisites
|
||||
|
@ -51,6 +53,6 @@ This is an alias for the Pulp command:
|
|||
pulp browserify --to dist/app.js
|
||||
```
|
||||
|
||||
If you open `dist/index.html` you should now have a basic working Halogen app.
|
||||
If you open `dist/index.html` you should now have a basic working Halogen app.
|
||||
|
||||
That's pretty much it. Have fun with Halogen!
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"purescript-console": "^0.1.0",
|
||||
"purescript-halogen": "^0.6.1"
|
||||
"purescript-console": "^1.0.0",
|
||||
"purescript-halogen": "^0.9.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
"virtual-dom": "^2.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"pulp": "^8.1.0",
|
||||
"purescript": "^0.7.6"
|
||||
"pulp": "^9.0.1",
|
||||
"purescript": "^0.9.1",
|
||||
"purescript-psa": "^0.3.9"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@ module Main where
|
|||
|
||||
import Prelude
|
||||
|
||||
import Control.Monad.Eff (Eff())
|
||||
import Control.Monad.Eff (Eff)
|
||||
|
||||
import Halogen
|
||||
import Halogen as H
|
||||
import Halogen.HTML.Events.Indexed as HE
|
||||
import Halogen.HTML.Indexed as HH
|
||||
import Halogen.Util (awaitBody, runHalogenAff)
|
||||
import Halogen.HTML.Indexed as H
|
||||
import Halogen.HTML.Events.Indexed as E
|
||||
|
||||
data Query a = ToggleState a
|
||||
|
||||
|
@ -16,32 +16,32 @@ type State = { on :: Boolean }
|
|||
initialState :: State
|
||||
initialState = { on: false }
|
||||
|
||||
ui :: forall g. Component State Query g
|
||||
ui = component { render, eval }
|
||||
ui :: forall g. H.Component State Query g
|
||||
ui = H.component { render, eval }
|
||||
where
|
||||
|
||||
render :: State -> ComponentHTML Query
|
||||
render :: State -> H.ComponentHTML Query
|
||||
render state =
|
||||
H.div_
|
||||
[ H.h1_
|
||||
[ H.text "Hello world!" ]
|
||||
, H.p_
|
||||
[ H.text "Why not toggle this button:" ]
|
||||
, H.button
|
||||
[ E.onClick (E.input_ ToggleState) ]
|
||||
[ H.text
|
||||
HH.div_
|
||||
[ HH.h1_
|
||||
[ HH.text "Hello world!" ]
|
||||
, HH.p_
|
||||
[ HH.text "Why not toggle this button:" ]
|
||||
, HH.button
|
||||
[ HE.onClick (HE.input_ ToggleState) ]
|
||||
[ HH.text
|
||||
if not state.on
|
||||
then "Don't push me"
|
||||
else "I said don't push me!"
|
||||
]
|
||||
]
|
||||
|
||||
eval :: Natural Query (ComponentDSL State Query g)
|
||||
eval :: Query ~> H.ComponentDSL State Query g
|
||||
eval (ToggleState next) = do
|
||||
modify (\state -> { on: not state.on })
|
||||
H.modify (\state -> { on: not state.on })
|
||||
pure next
|
||||
|
||||
main :: Eff (HalogenEffects ()) Unit
|
||||
main :: Eff (H.HalogenEffects ()) Unit
|
||||
main = runHalogenAff do
|
||||
body <- awaitBody
|
||||
runUI ui initialState body
|
||||
H.runUI ui initialState body
|
||||
|
|
Loading…
Reference in New Issue