a simple and fast Elm-like library also inspired by Halogen.
Documentation is published on Pursuit
moduleExample.CounterwhereimportPreludeimportEffect (Effect)
importPha.App (sandbox)
importPha.Html (Html)
importPha.HtmlasHimportPha.Html.AttributesasPimportPha.Html.EventsasEtypeModel=IntdataMsg = Increment|Decrementinit∷Model
init = 0update∷Msg→Model→Model
update Increment n = n + 1
update Decrement n = n - 1view∷Model→HtmlMsg
view counter = H.div []
[ H.button [E.onClick \_ → Decrement] [H.text "-"]
, H.span [] [H.text $ show counter]
, H.button [E.onClick \_ → Increment] [H.text "+"]
]
main∷EffectUnit
main = sandbox {init, update, view, selector: "#root"}moduleExample.CounterwhereimportPreludeimportEffect (Effect)
importEffect.Aff (Aff)
importEffect.Random (randomInt)
importPha.App (app)
importPha.Html (Html)
importPha.HtmlasHimportPha.Html.AttributesasPimportPha.Html.EventsasEimportPha.Update (Update, liftEffect, put)
typeModel=IntdataMsg = RollDiceupdate∷Msg→UpdateModelMsgAffUnit
update RollDice = put =<< liftEffect (randomInt 16)
view∷State→HtmlMsg
view dice = H.div []
[ H.button [E.onClick \_ → RollDice] [H.text "Roll dice"]
, H.span [] [H.text $ show dice]
]
main∷EffectUnit
main =
app
{ init: { model: 0, msg: JustRollDice }
, view
, update
, selector: "#root"
}https://github.com/gbagan/purescript-pha-examples/tree/master/src