wryte: Pretty output for source generators

[ bsd3, library, web ] [ Propose Tags ]

Wryte provides a convenient API for semi-automatically indented source code output.

[Skip to Readme]


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],,
Dependencies base (>=4.8 && <5), mtl, text [details]
License BSD-3-Clause
Copyright 2017 Tobias Dammers
Author Tobias Dammers
Maintainer tdammers@gmail.com
Revised Revision 1 made by HerbertValerioRiedel at 2017-05-26T12:52:08Z
Category Web
Home page https://github.com/tdammers/wryte#readme
Source repo head: git clone https://github.com/tdammers/wryte
Uploaded by TobiasDammers at 2017-05-26T10:30:45Z
Distributions NixOS:
Reverse Dependencies 2 direct, 2 indirect [details]
Downloads 2021 total (9 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-05-26 [all 1 reports]

Readme for wryte-

[back to package description]


Pretty-printed source code with semi-automatic indentation


Wryte provides an API for generating textual source code with pretty indentation and alignment. To achieve this, it tracks source column position, newlines, and current indentation / alignment internally, and provides a monadic API to conveniently manage these.


The usual; cabal install wryte, or add wryte to your stack extra-dependencies.

Basic Usage

putStrLn . runWryte_ defWryteOptions $ do
  wryteLn "module Main where"
  wryteLn ""
  wryteLn "main = do"
  indented $ do
    wryteLn "putStrLn \"Hello, world!\"

Indentation is tracked monadically, such that indented acts as a wrapper that automatically prepends indentation to each new line. Indentations stack up, so you can safely nest them, and they will do the right thing.