Package

purescript-pha

Repository
gbagan/purescript-pha
License
MIT
Uploaded by
gbagan
Published on
2019-11-30T08:34:09Z

Yet another Elm-like library based on Hyperapp and purescript-run

https://github.com/jorgebucaran/hyperapp

https://github.com/natefaubion/purescript-run

Documentation

Documentation is published on Pursuit

Minimal example

module Example.Counter where
import Prelude hiding (div)
import Effect (Effect)
import Pha (VDom, text)
impor Pha (sandbox, attachTo)
import Pha.Elements (div, span, button)
import Pha.Events (onclick)

type State = Int
data Msg = Increment | Decrement

init  State
init = 0

update  Msg  State  State
update Increment = (_ + 1)
update Decrement = (_ - 1)

view  State  VDom Msg
view counter = 
    div []
    [   button [onclick Decrement] [text "-"]
    ,   span [] [text $ show counter]
    ,   button [onclick Increment] [text "-"]
    ]

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

Other examples

Counter2 (delayed action, raw events) Code | HTML

Randomness (+ animation) Code | HTML

Decoder (decoding events) Code | HTML

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

Cats (HTTP, json) Code | HTML