nano-ui-form: Validated forms for nano-ui, built on ditto

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

Applicative forms whose inputs are nano-ui widgets, with validation errors shown under each field.


[Skip to Readme]

Flags

Manual Flags

NameDescriptionDefault
sdl

Build the SDL3 window example

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.20 && <4.23), containers (>=0.6.7 && <0.9), ditto (>=0.5 && <0.6), effectful-core (>=2.5 && <2.8), hashable (>=1.4 && <1.6), nano-ui (>=0.1 && <0.2), nano-ui-form, text (>=2.0 && <2.2) [details]
Tested with ghc ==9.10.3 || ==9.14.1
License MIT
Author goolord
Maintainer zacharyachurchill@gmail.com
Uploaded by goolord at 2026-09-17T17:02:34Z
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-form)
Distributions
Executables nano-ui-form-example
Downloads 3 total (3 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-form-0.1.0.0

[back to package description]

nano-ui-form

Forms for nano-ui, built on ditto.

A form is an applicative value. Each input draws a nano-ui widget and parses its value; validators attach errors that appear under the field.

{-# LANGUAGE OverloadedStrings #-}

import Data.Text (Text)
import NanoUI (NanoUI, label)
import NanoUI.Form hiding (label)

data Signup = Signup Text Text

signup :: Form Text Signup
signup =
  Signup
    <$> withFieldErrors (inputText "Name" "" `prove` notEmpty "Name is required")
    <*> withFieldErrors (inputText "Email" "" `prove` validEmail (const "Not an email address"))

view :: NanoUI ()
view = do
  submitted <- nanoFormSubmit "signup" "Sign up" signup
  case submitted of
    Just (Signup name _) -> label ("Welcome, " <> name)
    Nothing -> pure ()

nanoFormSubmit adds a submit button and yields the value on the frame the form is submitted. nanoFormLive yields the value whenever the form is valid, nanoFormEx takes a FormConfig, and runNanoForm returns the form's view and result separately.

Running

cabal run nano-ui-form-example -f sdl

The example needs nano-ui-sdl, behind this package's sdl flag (off by default, and on in this repository's cabal.project). The library itself does not depend on a backend.