template-haskell-util: Some utilities for template Haskell.

[ library, mit, template-haskell ] [ Propose Tags ] [ Report a vulnerability ]

Some functions that might be useful when you use template haskell.


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.1.0
Change log changelog.md
Dependencies base (>=4 && <5), GenericPretty (>=1.2.1), ghc-prim (>=0.3.1.0), template-haskell (>=2.9) [details]
License MIT
Author songzh
Maintainer Haskell.Zhang.Song@hotmail.com
Category Template Haskell
Home page https://github.com/HaskellZhangSong/TemplateHaskellUtils
Uploaded by songzh at 2015-03-02T09:33:57Z
Distributions
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 3795 total (15 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2015-03-02 [all 1 reports]

Readme for template-haskell-util-0.1.1.0

[back to package description]

TemplateHaskellUtils

useful functions for you to write template Haskell code

some examples ** Prettyprint

> runQ [| (1+1) * 5|] >>= pp -- or use
> printiQ  [| (1+1) * 5|]
InfixE (Just InfixE (Just LitE (IntegerL 1))
                  (VarE (Name (OccName "+")
                               (NameG' VarName
                                       (PkgName "base")
                                       (ModName "GHC.Num"))))
                   (Just LitE (IntegerL 1)))
      (VarE (Name (OccName "*")
                  (NameG' VarName
                          (PkgName "base")
                          (ModName "GHC.Num"))))
      (Just LitE (IntegerL 5))

** Other helper functions

-- | Apply a list of expression [(+), 1, 2] to (+) 1 2
appExp :: [ExpQ] -> ExpQ

-- | Apply a type constructor, convert [a, b, c] to a b c
appConT :: [TypeQ] -> TypeQ

-- | convert [a, b, c] to a -> b -> c
curryType :: [TypeQ] -> TypeQ