nano-ui-emit: Statically typed messages and reducers for nano-ui

[ graphics, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

Typed emitting views, widget adapters, and headless reducer runners.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.2.0.0
Change log CHANGELOG.md
Dependencies base (>=4.20 && <4.23), nano-ui (>=0.2 && <0.3) [details]
Tested with ghc ==9.10.3 || ==9.14.1
License MIT
Author goolord
Maintainer zacharyachurchill@gmail.com
Uploaded by goolord at 2026-12-03T05:00:33Z
Category Graphics
Home page https://github.com/goolord/nano-ui
Bug tracker https://github.com/goolord/nano-ui/issues
Source repo head: git clone https://github.com/goolord/nano-ui.git(packages/nano-ui-emit)
Distributions
Reverse Dependencies 3 direct, 0 indirect [details]
Downloads 0 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for nano-ui-emit-0.2.0.0

[back to package description]

nano-ui-emit

Statically typed message emission and Elm-style reducers for nano-ui. NanoUI.Emit re-exports all of NanoUI, so standard containers, widgets, and overlays run inside NanoUIE msg a unchanged.

{-# LANGUAGE OverloadedStrings #-}

import NanoUI.Emit

data Msg = Save | SetVolume Float

view :: Float -> NanoUIE Msg ()
view volume = column $ do
  label "Settings"
  emitChanged (slider 0 100) volume SetVolume
  emitWhen (button "Save") Save

NanoUIE msg a is a NanoUI a action with a typed message sink in scope (?emit). Give top-level emitting views an explicit NanoUIE Msg a signature so GHC keeps the sink in scope, and avoid calling emit unconditionally at the top level of a view (a frame can run two passes).

  • emit :: msg -> NanoUIE msg (): Emits a message directly.
  • mapMessages :: (child -> parent) -> NanoUIE child a -> NanoUIE parent a: Embeds reusable child views in traversal order.
  • emitWhen, emitChanged, emitEdited: Adapt NanoUI Bool and Var-based widgets to emit messages on activation or user edits.

Running views

Backend runners (runSdlAppReduce, runRgfwAppReduce, runSdlWebAppReduce) pair a model -> NanoUIE msg () view with a pure update function msg -> model -> model.

For headless tests and custom loops, runFrameE collects emitted messages from a frame, runFrameReduce folds them into the model (flagging another frame when the model changes), and runClickReduce drives a press/release click pair.

Documentation