The th-to-exp package

[Tags:library, test]

This package provides a way to persist data from compile-time to runtime by producing Template Haskell expressions that evaluate to particular values. For example, if you have a value @Just 1@, then @toExp (Just 1)@ will produce the /expression/ @[e| Just 1 |]@, which can be used in a splice. For a more direct example, here’s what that looks like without the quasiquote notation:

>>> toExp (Just 1) AppE (ConE GHC.Base.Just) (LitE (IntegerL 1))

This is done by using a typeclass, 'ToExp', that can be automatically derived for types that have a 'Generic' instance.


[Skip to Readme]

Properties

Versions 0.0.1.0
Dependencies base (>=4.9.0.0 && <5), template-haskell [details]
License ISC
Author
Maintainer Alexis King
Category Template Haskell
Home page https://github.com/lexi-lambda/th-to-exp#readme
Bug tracker https://github.com/lexi-lambda/th-to-exp/issues
Source repository head: git clone https://github.com/lexi-lambda/th-to-exp
Uploaded Tue Nov 8 00:23:25 UTC 2016 by lexi_lambda
Distributions LTSHaskell:0.0.1.0, NixOS:0.0.1.0, Stackage:0.0.1.0, Tumbleweed:0.0.1.0
Downloads 53 total (5 in the last 30 days)
Votes
1 []
Status Docs available [build log]
Last success reported on 2016-11-17 [all 1 reports]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for th-to-exp

Readme for th-to-exp-0.0.1.0

th-to-exp Build Status

th-to-exp is a package that provides a way to persist data from compile-time to runtime by producing Template Haskell expressions that evaluate to particular values. For example, if you have a value Just 1, then toExp (Just 1) will produce the expression [e| Just 1 |], which can be used in a splice. For a more direct example, here’s what that looks like without the quasiquote notation:

> toExp (Just 1)
AppE (ConE GHC.Base.Just) (LitE (IntegerL 1))

This is done by using a typeclass, ToExp, that can be automatically derived for types that have a Generic instance.