pretty-sop

A generic pretty-printer using generics-sop

Version on this page:0.2.0.3
LTS Haskell 22.14:0.2.0.3@rev:1
Stackage Nightly 2024-03-28:0.2.0.3@rev:1
Latest on Hackage:0.2.0.3@rev:1

See all snapshots pretty-sop appears in

BSD-3-Clause licensed by Edsko de Vries, Andres Löh
Maintained by [email protected]
This version can be pinned in stack with:pretty-sop-0.2.0.3@sha256:b1ebdd5db5affed4b2b8bbbf0ca214475f82664c3268073d083bbf9db91acb01,2692

Module documentation for 0.2.0.3

## pretty-sop

[![Build Status](https://travis-ci.org/well-typed/pretty-sop.svg?branch=master)](https://travis-ci.org/well-typed/pretty-sop)
[![Hackage](https://img.shields.io/hackage/v/pretty-sop.svg)](https://hackage.haskell.org/package/pretty-sop)

This library contains a generic implementation of the `prettyVal` function
from the [pretty-show](https://hackage.haskell.org/package/pretty-show) package.
Using the pretty printer, values can easily be rendered to strings and HTML
documents in a uniform way.

This library makes use of the [generics-sop](https://github.com/well-typed/generics-sop)
package and is an example of a generic function defined in the SOP style.

This is the development repository. For releases, look on
[Hackage](https://hackage.haskell.org/package/pretty-sop).


## Example

```haskell
{-# LANGUAGE DeriveGeneric #-}

import Generics.SOP.PrettyVal
import Generics.SOP
import qualified GHC.Generics as G
import Text.Show.Pretty


data Car = Car
{ name :: String
, seats :: Int
} deriving (G.Generic)

instance Generic Car
instance HasDatatypeInfo Car
instance PrettyVal Car where
prettyVal = gprettyVal

main :: IO ()
main = putStrLn $ dumpStr $ Car "test" 3
```

would print:

```text
Car { name = test , seats = 3 }
```