present: Make presentations for data types.

[ bsd3, development, library ] [ Propose Tags ]

Make presentations for data types.


[Skip to Readme]
Versions 0.0.0, 1.0, 1.1, 2.0, 2.1, 2.2, 4.0.0, 4.0.1, 4.0.2, 4.1.0 (info)
Dependencies base (==4.*), template-haskell [details]
License BSD-3-Clause
Copyright 2016 Chris Done
Author Chris Done
Maintainer chrisdone@gmail.com
Category Development
Home page https://github.com/chrisdone/present
Uploaded by ChrisDone at Fri Mar 25 22:01:51 UTC 2016
Distributions LTSHaskell:4.1.0, NixOS:4.1.0, Stackage:4.1.0, openSUSE:4.1.0
Downloads 5159 total (24 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2016-11-27 [all 2 reports]
Hackage Matrix CI

Modules

  • Present

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for present-4.0.1

[back to package description]

present

Make presentations for data types.

Install

Requires: GHC 7.10.3

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

$ sh install-to-global-db.sh

To remove it later:

$ sh remove-from-global-db.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

Usage

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

λ> :present 123
123

λ> data X a = X a Int

λ> :present X 5 1
X 5 1

λ> :present S88.pack "hi"
PS (ForeignPtr GHC.Prim.Addr# (PlainPtr GHC.Prim.MutableByteArray#)) 0 2

λ> :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]

Extension

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
5