Make presentations for data types.

Version on this page:4.1.0
LTS Haskell 12.22:4.1.0
Stackage Nightly 2018-12-10:4.1.0
Latest on Hackage:4.1.0

See all snapshots present appears in

BSD3 licensed by Chris Done
Maintained by

Module documentation for 4.1.0

There are no documented modules for this package.


Make presentations for data types.


Requires: GHC 7.10.3

Install globally into your GHC’s global database (via stack) with:

$ sh

To remove it later:

$ sh

To be added: install via stack install present, but it needs to be added to an LTS/nightly version first.

Customizing GHCi

Add to the following to your ~/.ghci:

:seti -XTemplateHaskell
:def presentDebug \e -> return ("let it = " ++ e ++ "\n$(Present.presentIt)")
:def presentQualified \e -> return ("let it = " ++ e ++ "\nPrelude.putStrLn (Present.toShow True $(Present.presentIt))")
:def present \e -> return ("let it = " ++ e ++ "\nPrelude.putStrLn (Present.toShow False $(Present.presentIt))")
:set -package present


bash-3.2$ stack exec ghci
GHCi, version 7.10.3:  :? for help
package flags have changed, resetting and loading new packages...
λ> :present "hi"

λ> :present 123

λ> :present (5.2,"hi",1,'a')

λ> data X a = X a Int

λ> :present X 5 1
X 5 1

λ> :present S88.pack "hi"

λ> :present print
<a_0 -> GHC.Types.IO ()>

λ> :present print ()
IO (<GHC.Prim.State# GHC.Prim.RealWorld -> (GHC.Prim.State# GHC.Prim.RealWorld, a_0)>)

λ> :present undefined
<_ :: t_0>

λ> :present id
<a_0 -> a_0>

λ> :present [undefined]
[<_ :: t_0>]


You can write your own instances like this:

λ> data X = X Int
λ> :present X 5
X 5
λ> instance Present0 X where present0 = ("X",\(X x) -> IntegerPresentation "X" (show x))
λ> :present X 5

Detailed output

λ> :presentDebug (2.5,"hi",1,'a')
     [("Floating",IntegerPresentation "GHC.Types.Double" "2.5")
     ,("Show",IntegerPresentation "GHC.Types.Double" "2.5")
     ,("Rational",IntegerPresentation "GHC.Types.Double" "5/2")
      ,DataTypePresentation "GHC.Types.Double"
                            [PrimitivePresentation "GHC.Prim.Double#"])]
     [("String",StringPresentation "String" "hi")
     ,("List of characters"
            [("Character",CharPresentation "GHC.Types.Char" "h")
            ,("Unicode point"
                [("Decimal",IntegerPresentation "GHC.Types.Char" "104")
                ,("Hexadecimal",IntegerPresentation "GHC.Types.Char" "68")
                ,("Binary",IntegerPresentation "GHC.Types.Char" "1101000")])
             ,DataTypePresentation "GHC.Types.Char"
                                   [PrimitivePresentation "GHC.Prim.Char#"])]
            [("Character",CharPresentation "GHC.Types.Char" "i")
            ,("Unicode point"
                [("Decimal",IntegerPresentation "GHC.Types.Char" "105")
                ,("Hexadecimal",IntegerPresentation "GHC.Types.Char" "69")
                ,("Binary",IntegerPresentation "GHC.Types.Char" "1101001")])
             ,DataTypePresentation "GHC.Types.Char"
                                   [PrimitivePresentation "GHC.Prim.Char#"])]])]
     [("Decimal",IntegerPresentation "GHC.Integer.Type.Integer" "1")
     ,("Hexadecimal",IntegerPresentation "GHC.Integer.Type.Integer" "1")
     ,("Binary",IntegerPresentation "GHC.Integer.Type.Integer" "1")
      ,DataTypePresentation "GHC.Integer.Type.Integer"
                            [PrimitivePresentation "GHC.Prim.Int#"])]
     [("Character",CharPresentation "GHC.Types.Char" "a")
     ,("Unicode point"
         [("Decimal",IntegerPresentation "GHC.Types.Char" "97")
         ,("Hexadecimal",IntegerPresentation "GHC.Types.Char" "61")
         ,("Binary",IntegerPresentation "GHC.Types.Char" "1100001")])
      ,DataTypePresentation "GHC.Types.Char"
                            [PrimitivePresentation "GHC.Prim.Char#"])]]
Depends on 2 packages:
Used by 1 package:
comments powered byDisqus