Package

purescript-pha

Repository
gbagan/purescript-pha
License
MIT
Uploaded by
gbagan
Published on
2021-04-09T11:49:10Z

Elm-like library

Documentation

Documentation is published on Pursuit

Minimal example

module Example.Counter where
import Prelude
import Effect (Effect)
import Pha (VDom, text)
import Pha.App (sandbox)
import Pha.Elements as H
import Pha.Events as E

type State = Int
data Msg = Increment | Decrement

init  State
init = 0

update  Msg  State  State
update Increment n = n + 1
update Decrement n = n - 1

view  State  VDom Msg
view counter = 
    H.div []
    [   H.button [E.onClick Decrement] [text "-"]
    ,   H.span [] [text $ show counter]
    ,   H.button [E.onClick Increment] [text "+"]
    ]

main  Effect Unit
main = sandbox {init, update, view, selector: "#root"}

Other examples

Randomness (+ animation) Code | Demo

Inputs (event effects, text and checkbox inputs) Code | Demo

Cats (HTTP, json) Code | Demo