Update for latest Halogen and PureScript 0.9.1
parent
960f2f1128
commit
888c339023
|
@ -1,5 +1,7 @@
|
||||||
# purescript-halogen-template
|
# 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.
|
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
|
## Prerequisites
|
||||||
|
@ -51,6 +53,6 @@ This is an alias for the Pulp command:
|
||||||
pulp browserify --to dist/app.js
|
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!
|
That's pretty much it. Have fun with Halogen!
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"purescript-console": "^0.1.0",
|
"purescript-console": "^1.0.0",
|
||||||
"purescript-halogen": "^0.6.1"
|
"purescript-halogen": "^0.9.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
"virtual-dom": "^2.1.1"
|
"virtual-dom": "^2.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"pulp": "^8.1.0",
|
"pulp": "^9.0.1",
|
||||||
"purescript": "^0.7.6"
|
"purescript": "^0.9.1",
|
||||||
|
"purescript-psa": "^0.3.9"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,12 @@ module Main where
|
||||||
|
|
||||||
import Prelude
|
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.Util (awaitBody, runHalogenAff)
|
||||||
import Halogen.HTML.Indexed as H
|
|
||||||
import Halogen.HTML.Events.Indexed as E
|
|
||||||
|
|
||||||
data Query a = ToggleState a
|
data Query a = ToggleState a
|
||||||
|
|
||||||
|
@ -16,32 +16,32 @@ type State = { on :: Boolean }
|
||||||
initialState :: State
|
initialState :: State
|
||||||
initialState = { on: false }
|
initialState = { on: false }
|
||||||
|
|
||||||
ui :: forall g. Component State Query g
|
ui :: forall g. H.Component State Query g
|
||||||
ui = component { render, eval }
|
ui = H.component { render, eval }
|
||||||
where
|
where
|
||||||
|
|
||||||
render :: State -> ComponentHTML Query
|
render :: State -> H.ComponentHTML Query
|
||||||
render state =
|
render state =
|
||||||
H.div_
|
HH.div_
|
||||||
[ H.h1_
|
[ HH.h1_
|
||||||
[ H.text "Hello world!" ]
|
[ HH.text "Hello world!" ]
|
||||||
, H.p_
|
, HH.p_
|
||||||
[ H.text "Why not toggle this button:" ]
|
[ HH.text "Why not toggle this button:" ]
|
||||||
, H.button
|
, HH.button
|
||||||
[ E.onClick (E.input_ ToggleState) ]
|
[ HE.onClick (HE.input_ ToggleState) ]
|
||||||
[ H.text
|
[ HH.text
|
||||||
if not state.on
|
if not state.on
|
||||||
then "Don't push me"
|
then "Don't push me"
|
||||||
else "I said 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
|
eval (ToggleState next) = do
|
||||||
modify (\state -> { on: not state.on })
|
H.modify (\state -> { on: not state.on })
|
||||||
pure next
|
pure next
|
||||||
|
|
||||||
main :: Eff (HalogenEffects ()) Unit
|
main :: Eff (H.HalogenEffects ()) Unit
|
||||||
main = runHalogenAff do
|
main = runHalogenAff do
|
||||||
body <- awaitBody
|
body <- awaitBody
|
||||||
runUI ui initialState body
|
H.runUI ui initialState body
|
||||||
|
|
Loading…
Reference in New Issue