Update to PureScript 0.14 and Halogen 6 (#29)

master
Raptazure 2021-03-10 04:02:04 +08:00 committed by GitHub
parent 9858165d57
commit 4975e73125
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 15 deletions

View File

@ -1,13 +1,13 @@
{ {
"private": true, "private": true,
"devDependencies": { "devDependencies": {
"parcel": "^1.12.4", "parcel": "1.12.3",
"purescript": "^0.13.8", "purescript": "^0.14.0",
"spago": "^0.15.3" "spago": "^0.19.1"
}, },
"scripts": { "scripts": {
"build": "spago build", "build": "spago build",
"serve": "parcel dev/index.html --open", "serve": "parcel dev/index.html --open",
"build-prod": "mkdir -p prod && cp dev/index.html prod/ && rm -rf dist && spago bundle-app --to prod/index.js && parcel build prod/index.html" "build-prod": "mkdir -p prod && cp dev/index.html prod/ && rm -rf dist && spago bundle-app --to prod/index.js && parcel build prod/index.html"
} }
} }

View File

@ -118,7 +118,7 @@ let additions =
-} -}
let upstream = let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20200615/packages.dhall sha256:5d0cfad9408c84db0a3fdcea2d708f9ed8f64297e164dc57a7cf6328706df93a https://raw.githubusercontent.com/purescript/package-sets/a0938edbed99b8739dcfc9303bda8e264f7fe853/src/packages.dhall sha256:595d52db8e1a061c5b5b7bddeea05c3d7167cd8ead86f19554611c568464f21f
let overrides = {=} let overrides = {=}

View File

@ -1,35 +1,34 @@
module App.Button where module App.Button where
import Prelude import Prelude
import Data.Maybe (Maybe(..))
import Halogen as H import Halogen as H
import Halogen.HTML as HH import Halogen.HTML as HH
import Halogen.HTML.Events as HE import Halogen.HTML.Events as HE
type State = { count :: Int } type State
= { count :: Int }
data Action = Increment data Action
= Increment
component :: forall q i o m. H.Component HH.HTML q i o m component :: forall q i o m. H.Component q i o m
component = component =
H.mkComponent H.mkComponent
{ initialState: \_ -> { count: 0 } { initialState: \_ -> { count: 0 }
, render , render
, eval: H.mkEval $ H.defaultEval { handleAction = handleAction } , eval: H.mkEval H.defaultEval { handleAction = handleAction }
} }
render :: forall cs m. State -> H.ComponentHTML Action cs m render :: forall cs m. State -> H.ComponentHTML Action cs m
render state = render state =
HH.div_ HH.div_
[ HH.p_ [ HH.p_
[ HH.text $ "You clicked " <> show state.count <> " times" ] [ HH.text $ "You clicked " <> show state.count <> " times" ]
, HH.button , HH.button
[ HE.onClick \_ -> Just Increment ] [ HE.onClick \_ -> Increment ]
[ HH.text "Click me" ] [ HH.text "Click me" ]
] ]
handleAction :: forall cs o m. Action → H.HalogenM State Action cs o m Unit handleAction :: forall cs o m. Action → H.HalogenM State Action cs o m Unit
handleAction = case _ of handleAction = case _ of
Increment -> Increment -> H.modify_ \st -> st { count = st.count + 1 }
H.modify_ \st -> st { count = st.count + 1 }