reflex-vty: Reflex FRP host and widgets for VTY applications

[ bsd3, frp, library, program, vty ] [ Propose Tags ] [ Report a vulnerability ]

Build terminal applications using functional reactive programming (FRP) with Reflex FRP (https://reflex-frp.org). .


[Skip to Readme]

Flags

Manual Flags

NameDescriptionDefault
leaktest

Build the space-leak profiling repro (src-bin/leaktest.hs)

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

Versions [RSS] 0.1.0.0, 0.1.1.0, 0.1.1.1, 0.1.2.0, 0.1.2.1, 0.1.3.0, 0.1.4.0, 0.1.4.1, 0.1.4.2, 0.2.0.0, 0.2.0.1, 0.3.0.0, 0.3.1.0, 0.3.1.1, 0.4.0.0, 0.4.1.0, 0.4.1.1, 0.5.0.0, 0.5.1.0, 0.5.2.0, 0.5.2.1, 0.6.0.0, 0.6.1.0, 0.6.1.1, 0.6.2.0, 0.6.2.1, 1.0.0.0, 1.0.0.1, 1.1.0.0
Change log ChangeLog.md
Dependencies async (>=2.2.6 && <2.3), base (>=4.10.0 && <4.22), bimap (>=0.3.3 && <0.6), bytestring (>=0.12.1 && <0.13), containers (>=0.5.0 && <0.8), data-default (>=0.7.1 && <0.9), dependent-map (>=0.4 && <0.5), dependent-sum (>=0.7 && <0.8), exception-transformers (>=0.4.0 && <0.5), exceptions (>=0.10 && <0.11), mmorph (>=1.1 && <1.3), mtl (>=2.2.2 && <2.4), ordered-containers (>=0.2.2 && <0.3), primitive (>=0.6.3 && <0.10), ref-tf (>=0.4.0 && <0.6), reflex (>=0.9.2 && <1), reflex-vty, stm (>=2.4 && <2.6), text (>=1.2.3 && <2.2), time (>=1.8.0 && <1.15), transformers (>=0.5.5 && <0.7), unix (>=2.7 && <2.10), vty (>=6.0 && <6.7), vty-crossplatform (>=0.1 && <0.6) [details]
Tested with ghc ==9.8.4 || ==9.10.1 || ==9.12.2
License BSD-3-Clause
Copyright 2020 Obsidian Systems LLC
Author Obsidian Systems LLC
Maintainer maintainer@obsidian.systems
Uploaded by abrar at 2026-06-27T14:26:40Z
Category FRP
Source repo head: git clone https://github.com/reflex-frp/reflex-vty
Distributions
Reverse Dependencies 2 direct, 0 indirect [details]
Executables leaktest, examples, example
Downloads 4840 total (68 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-06-27 [all 1 reports]

Readme for reflex-vty-1.1.0.0

[back to package description]

reflex-vty

Build terminal user interfaces with functional reactive programming.

reflex-vty provides a Reflex FRP host and a library of reactive widgets for Vty terminal applications: layout, text input and editing, boxes, scrolling, mouse support, focus management, and theming.

Haskell Hackage Github CI Obsidian BSD3 License

reflex-vty example walkthrough: gradient menu, to-do list, scrollbar modes, and styling showcase

A minimal app

{-# LANGUAGE OverloadedStrings #-}
module Main where

import Reflex.Vty

main :: IO ()
main = mainWidget def $ do
  text "Hello, reflex-vty! Press Ctrl+C to quit."
  ctrlc

mainWidget takes a VtyAppConfig (def for the defaults) and runs a widget until the Event t () it returns fires. Here that is ctrlc, which fires when the user presses Ctrl+C. Docs are available on Hackage.

Features

  • Layout: arrange widgets into rows and columns (tile / grout) with fixed or proportional (stretch) size constraints.
  • Focus: tab-cycling focus management across the focusable widgets in a layout (tabNavigation).
  • Text: word-wrapped text display, rich text with per-span attributes, and single- or multi-line text input backed by a zipper that handles wide characters, tabs, and wrapping.
  • Inputs: clickable buttons, hyperlinks, and checkboxes.
  • Boxes: single, thick, double, rounded, ASCII, inner-half, and outer-half border styles, with optional titles and horizontal rules.
  • Scrolling: scrollable containers with programmatic scrolling, auto-scroll-to-bottom mode, and a visual scrollbar with four visibility modes (always, thumb-only, while-scrolling, hidden).
  • Split panes: fixed horizontal and vertical splits, plus a mouse-draggable splitter you can resize at runtime (splitVDrag).
  • Mouse: button clicks, drags (with from/to/button/modifier tracking), scroll-wheel events, and last-known mouse-position tracking.
  • Keyboard: individual key and key-combo events, plus input filtering.
  • Runtime: alternate-screen mode, terminal cursor control (shape, visibility, and position), bracketed paste, terminal focus tracking, resize, and POSIX signal handling.
  • Theming: a Theme record with presets (default, dark, charm, dracula, nord, zenburn, gruvbox). Widgets inherit the ambient theme and can override locally.
  • Declarative styling: Lip Gloss-inspired Style type with foreground/background colors, text attributes (bold/italic/underline/etc.), padding, margin, borders with per-side colors, width/height constraints, alignment, text transforms, tab expansion, inline mode, whitespace coloring, and border presets.
  • Color: RGB color type, operations (darken, lighten, complementary, mix, alpha), and gradients (Gradient1D, Gradient2D).
  • Compositing: Reflex.Vty.Canvas module with per-cell transparency for overlays and layered rendering.
  • Image composition: joinHorizontal/joinVertical/place utilities for composing rendered images.
  • Color profiles: automatic terminal color-capability detection (TrueColor/Ansi256/Ansi16/Ascii/NoTTY) with downsampling.

Run the bundled demo with cabal run example to see many of these in action: a text editor, a to-do list, scrollable text, clickable buttons, a live CPU-usage display with a true-color gradient bar, a scrollbar-modes demo, a terminal-cursor demo, and a little styling showcase featuring gradients, color operations, a canvas overlay, border presets, theming, and color-profile downsampling.

Each of these examples is a module in src-bin/Example/. You can run any of them with cabal run examples -- <name>.

spinner — an animated braille spinner spinner demo
progress — a gradient-filled progress bar progress bar demo
stopwatch — a tick-driven count-up timer stopwatch demo
timer — a count-down timer timer demo
textinput — a focused text-input field text input demo
pager — a scrollable text viewport pager demo
views — toggle between two views views demo

More demos: full-screen canvas animations (the classic Doom fire, a plasma field, a starfield, an animated splash) live on the examples page.

Feature requests, pull requests, and other feedback are welcome and appreciated (see the contribution guide).

How to Build

With reflex-platform

Enter a nix-shell for the project:

git clone https://github.com/reflex-frp/reflex-vty.git
cd reflex-vty
nix-shell

From within the nix-shell you can:

  • Run the example: cabal run example
  • Load the library in the repl: cabal repl reflex-vty
  • Build the example executable: cabal build example
  • Build the docs: cabal haddock
  • Run ghcid for immediate compiler feedback when you save a .hs file: ghcid -c "cabal repl library:reflex-vty executable:example test:reflex-vty-test --ghc-options=-Wall" -o ghcid-output.txt
  • etc.
Selecting a compiler

nix-shell defaults to GHC 9.8. The other compilers defined in release.nix are ghc94, ghc96, and ghc98. To enter a shell with one of them, pass it as the compiler argument:

nix-shell --argstr compiler ghc96

If you were previously building with a different compiler, you may need to run cabal clean first.

With cabal

Please see the tested-with field of the cabal file for known-compatible versions of GHC.

From the reflex-vty project directory:

# nix-shell -p cabal-install binutils icu # for nix users
cabal build          # to build the library, example, and test suite
cabal repl           # to enter a multi-repl covering all components
cabal repl example   # to enter a repl for the example executable only

About Obsidian Systems

reflex-vty is built and maintained by Obsidian Systems. We provide frontier engineering for high-assurance systems: we build production software in Haskell and Nix, and we're long-time stewards of open-source tooling like Obelisk, Reflex, and nix-thunk.

If you're working with Reflex, terminal or web UIs in Haskell, or Nix and want a partner to help design, build, or ship it, we'd love to hear from you.

License

reflex-vty is released under the BSD-3-Clause License, © 2018 Obsidian Systems LLC.