Build terminal applications using functional reactive programming (FRP) with Reflex FRP.
See the codeBuild 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.
{-# 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.
tile / grout) with fixed or proportional (stretch) size constraints.tabNavigation).splitVDrag).Theme record with presets (default, dark, charm, dracula, nord, zenburn, gruvbox). Widgets inherit the ambient theme and can override locally.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.RGB color type, operations (darken, lighten, complementary, mix, alpha), and gradients (Gradient1D, Gradient2D).Reflex.Vty.Canvas module with per-cell transparency for overlays and layered rendering.joinHorizontal/joinVertical/place utilities for composing rendered images.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 | ![]() |
progress — a gradient-filled progress bar | ![]() |
stopwatch — a tick-driven count-up timer | ![]() |
timer — a count-down timer | ![]() |
textinput — a focused text-input field | ![]() |
pager — a scrollable text viewport | ![]() |
views — toggle between two views | ![]() |
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).
Prebuilt Nix dependencies are available from https://nixcache.reflex-frp.org. NixOS users can enable the cache by following the binary cache setup instructions.
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:
cabal run examplecabal repl reflex-vtycabal build examplecabal haddockghcid -c "cabal repl library:reflex-vty executable:example test:reflex-vty-test --ghc-options=-Wall" -o ghcid-output.txtnix-shell defaults to GHC 9.12. The compilers defined in release.nix are ghc98, ghc910, and ghc912. To enter a shell with one of them, pass it as the compiler argument:
nix-shell --argstr compiler ghc98
If you were previously building with a different compiler, you may need to run cabal clean first.
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
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.
reflex-vty is released under the BSD-3-Clause License, © 2018 Obsidian Systems LLC.
Haskell
95.8%
Shell
2.2%
Nix
2.0%
Build terminal applications using functional reactive programming (FRP) with Reflex FRP.
See the codeBuild 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.
{-# 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.
tile / grout) with fixed or proportional (stretch) size constraints.tabNavigation).splitVDrag).Theme record with presets (default, dark, charm, dracula, nord, zenburn, gruvbox). Widgets inherit the ambient theme and can override locally.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.RGB color type, operations (darken, lighten, complementary, mix, alpha), and gradients (Gradient1D, Gradient2D).Reflex.Vty.Canvas module with per-cell transparency for overlays and layered rendering.joinHorizontal/joinVertical/place utilities for composing rendered images.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 | ![]() |
progress — a gradient-filled progress bar | ![]() |
stopwatch — a tick-driven count-up timer | ![]() |
timer — a count-down timer | ![]() |
textinput — a focused text-input field | ![]() |
pager — a scrollable text viewport | ![]() |
views — toggle between two views | ![]() |
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).
Prebuilt Nix dependencies are available from https://nixcache.reflex-frp.org. NixOS users can enable the cache by following the binary cache setup instructions.
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:
cabal run examplecabal repl reflex-vtycabal build examplecabal haddockghcid -c "cabal repl library:reflex-vty executable:example test:reflex-vty-test --ghc-options=-Wall" -o ghcid-output.txtnix-shell defaults to GHC 9.12. The compilers defined in release.nix are ghc98, ghc910, and ghc912. To enter a shell with one of them, pass it as the compiler argument:
nix-shell --argstr compiler ghc98
If you were previously building with a different compiler, you may need to run cabal clean first.
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
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.
reflex-vty is released under the BSD-3-Clause License, © 2018 Obsidian Systems LLC.
Haskell
95.8%
Shell
2.2%
Nix
2.0%