From 888c33902331f9fb269b685113ceade08184b555 Mon Sep 17 00:00:00 2001 From: Gary Burgess Date: Sat, 25 Jun 2016 18:34:02 +0100 Subject: [PATCH] Update for latest Halogen and PureScript 0.9.1 --- README.md | 4 +++- bower.json | 4 ++-- package.json | 5 +++-- src/Main.purs | 38 +++++++++++++++++++------------------- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 2aae021..935a105 100644 --- a/README.md +++ b/README.md @@ -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! diff --git a/bower.json b/bower.json index 7c55283..4e70ed4 100644 --- a/bower.json +++ b/bower.json @@ -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" } } diff --git a/package.json b/package.json index 8382314..85b3529 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/src/Main.purs b/src/Main.purs index 3ac9510..cf415af 100644 --- a/src/Main.purs +++ b/src/Main.purs @@ -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