freestyle: Freestyle TUI graphics

[ concurrency, graphics, library, mit, prettyprinter, stm ] [ Propose Tags ] [ Report a vulnerability ]

Concurrent, pretty terminal graphics


[Skip to Readme]

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 (<5.0), prettyprinter, stm, text [details]
License MIT
Copyright (c) David Cox
Author dopamane
Maintainer dwc1295@gmail.com
Uploaded by dopamane at 2026-05-25T22:11:30Z
Category Graphics, Concurrency, STM, Prettyprinter
Source repo head: git clone https://github.com/dopamane/freestyle
Distributions
Downloads 1 total (1 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 freestyle-0.1.0.0

[back to package description]

Freestyle

Create and display pretty terminal graphics

Construct a new handle and configuration:

  • a way to read state
  • a function to draw the current state
  • a function to layout the current doc
  • a function to render the SimpleDocStream to Text

Run the configuration using runFreestyle. Note, it has an Eq ann constraint. Freestyle re-renders the terminal if the SimpleDocStream ann changes. This way, apps may make state changes without causing terminal re-rendering.

The Freestyle handle supports on-the-fly state, draw, layout, and rendering changes. Use dynamic layout, rendering algorithms based on environment such as window size.

Example

import Freestyle

main :: IO ()
main = do
  s <- newTVarIO "FREESTYLE!!!FREESTYLE!!!FREESTYLE!!!"
  f <- newFreestyleIO
  concurrently_ (runFreestyle f $ cfg s) $
    forever $ do
      atomically $ modifyTVar' s rote
      threadDelay 200000
  where
    rote s = last s : init s

cfg :: TVar String -> FreestyleCfg String AnsiStyle
cfg s = FreestyleCfg
  { readState = readTVar s
  , drawState = \s' -> return $
    applyWhen (take 1 s' == "E") (annotate $ color Blue) $ pretty s'
  , layoutDoc = return . layoutPretty defaultLayoutOptions
  , renderDoc = return . renderLazy
  }

Development

cabal build
cabal run
cabal haddock