# nano-ui-emit
Statically typed message emission and Elm-style reducers for [nano-ui](https://github.com/goolord/nano-ui). `NanoUI.Emit` re-exports all of `NanoUI`, so standard containers, widgets, and overlays run inside `NanoUIE msg a` unchanged.
```haskell
{-# 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
- [The nano-ui Book: Elm-Style State](https://goolord.github.io/nano-ui/book/state/elm.html): Combining `NanoUIE` with local `Var` state and testing reducers.