miso 0.20.0.0 → 0.20.1.0
raw patch · 3 files changed
+46/−28 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- README.md +10/−8
- exe/Main.hs +27/−18
- miso.cabal +9/−2
README.md view
@@ -134,7 +134,7 @@ packages: - '.' extra-deps:- - miso-0.12.0.0+ - miso-0.18.0.0 setup-info: ghcjs:@@ -280,6 +280,8 @@ } ``` +Add the source from [Sample Application](#sample-application) to `app/Main.hs`+ Build the project ``` nix-build@@ -418,13 +420,13 @@ main :: IO () main = startApp App {..} where- initialAction = SayHelloWorld -- initial action to be executed on application load- model = 0 -- initial model- update = updateModel -- update function- view = viewModel -- view function- events = defaultEvents -- default delegated events- subs = [] -- empty subscription list- mountPoint = Nothing -- mount point for application (Nothing defaults to 'body')+ initialAction = SayHelloWorld -- initial action to be executed on application load+ model = 0 -- initial model+ update = updateModel -- update function+ view = viewModel -- view function+ events = defaultEvents -- default delegated events+ subs = [] -- empty subscription list+ mountPoint = Nothing -- mount point for application (Nothing defaults to 'body') -- | Updates model, optionally introduces side effects updateModel :: Action -> Model -> Effect Action Model
exe/Main.hs view
@@ -1,40 +1,49 @@+-- | Haskell language pragma {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-}++-- | Haskell module declaration module Main where +-- | Miso framework import import Miso import Miso.String +-- | Type synonym for an application model type Model = Int +-- | Sum type for application events+data Action+ = AddOne+ | SubtractOne+ | NoOp+ | SayHelloWorld+ deriving (Show, Eq)++-- | Entry point for a miso application main :: IO ()-main = startApp App { initialAction = SayHelloWorld, ..}+main = startApp App {..} where- model = 0- update = updateModel- view = viewModel- events = defaultEvents- mountPoint = Nothing- subs = []+ initialAction = SayHelloWorld -- initial action to be executed on application load+ model = 0 -- initial model+ update = updateModel -- update function+ view = viewModel -- view function+ events = defaultEvents -- default delegated events+ subs = [] -- empty subscription list+ mountPoint = Nothing -- mount point for application (Nothing defaults to 'body') +-- | Updates model, optionally introduces side effects updateModel :: Action -> Model -> Effect Action Model updateModel AddOne m = noEff (m + 1) updateModel SubtractOne m = noEff (m - 1) updateModel NoOp m = noEff m updateModel SayHelloWorld m = m <# do- putStrLn "Hello World!" >> pure NoOp--data Action- = AddOne- | SubtractOne- | NoOp- | SayHelloWorld- deriving (Show, Eq)+ putStrLn "Hello World" >> pure NoOp -viewModel :: Int -> View Action+-- | Constructs a virtual DOM from a model+viewModel :: Model -> View Action viewModel x = div_ [] [ button_ [ onClick AddOne ] [ text "+" ]- , text $ ms (show x)+ , text (ms x) , button_ [ onClick SubtractOne ] [ text "-" ] ]-
miso.cabal view
@@ -1,5 +1,5 @@ name: miso-version: 0.20.0.0+version: 0.20.1.0 category: Web, Miso, Data Structures license: BSD3 license-file: LICENSE@@ -7,6 +7,7 @@ maintainer: David M. Johnson <djohnson.m@gmail.com> homepage: http://github.com/dmjio/miso copyright: Copyright (c) 2017-2018 David M. Johnson+bug-reports: https://github.com/dmjio/miso/issues build-type: Simple extra-source-files: README.md cabal-version: >=1.22@@ -27,6 +28,12 @@ description: Builds Miso's examples +flag tests+ default:+ False+ description:+ Builds Miso's tests+ executable todo-mvc main-is: Main.hs@@ -209,7 +216,7 @@ executable tests main-is: Main.hs- if !impl(ghcjs)+ if !impl(ghcjs) || !flag(tests) buildable: False else hs-source-dirs: