Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pretty print record types?

Tags:

haskell

Given a record like Example {a = "a", b = "b", c = "c"} how can I pretty print any record type like this to make it easier to read (more human friendly)?

Somthing like:

Example {
  a = "a"
, b = "b"
, c = "c"
}

would be ideal.

I've tried pPrint from the pretty-show package but this doesn't seem to output any different to show.

like image 615
Chris Stryczynski Avatar asked Dec 13 '22 21:12

Chris Stryczynski


1 Answers

This can be achieved with: pretty-simple:

ghci> import Text.Pretty.Simple (pPrint)
ghci> data Example = Example { a, b, c :: String } deriving Show
ghci> pPrint Example {a = "a", b = "b", c = "c"}
Example 
    { a = "a"
    , b = "b"
    , c = "c"
    }
like image 90
Shersh Avatar answered Feb 16 '23 06:02

Shersh