https://github.com/dopamane/freestyle
Freestyle concurrent TUI
https://github.com/dopamane/freestyle
concurrency graphics haskell stm tui
Last synced: about 2 months ago
JSON representation
Freestyle concurrent TUI
- Host: GitHub
- URL: https://github.com/dopamane/freestyle
- Owner: dopamane
- License: mit
- Created: 2026-05-16T13:16:47.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2026-05-25T22:12:43.000Z (2 months ago)
- Last Synced: 2026-05-25T23:25:57.422Z (2 months ago)
- Topics: concurrency, graphics, haskell, stm, tui
- Language: Haskell
- Homepage:
- Size: 51.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```hs
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
```