names-th-0.2.0.3: Manipulate name strings for TH

Copyright | 2013 Kei Hibino
License | BSD3
Maintainer | ex8k.hibino@gmail.com
Stability | experimental
Portability | unknown
Safe Haskell | None
Language | Haskell2010

Language.Haskell.TH.Lib.Extra

Contents

- Extra template functions
- Pretty printing for `Q` monad
- Functions to print message or errors when compile time

Description

This module provides extra helper functions complementing Language.Haskell.TH.Lib

Synopsis

- integralE :: Integral a => a -> ExpQ
- simpleValD :: Name -> TypeQ -> ExpQ -> Q [Dec]
- maybeD :: (a -> Q [Dec]) -> Maybe a -> Q [Dec]
- pprQ :: (Functor m, Quasi m, Ppr a) => Q a -> m Doc
- reportWarning :: String -> Q ()
- reportError :: String -> Q ()

# Extra template functions

Extra functions to generate haskell templates.

integralE :: Integral a => a -> ExpQ Source #

Integer literal template from `Integral` types.

simpleValD :: Name -> TypeQ -> ExpQ -> Q [Dec] Source #

Generate declaration template from name, type and expression.

maybeD :: (a -> Q [Dec]) -> Maybe a -> Q [Dec] Source #

May generate declaration template.

# Pretty printing for `Q` monad

Pretty printing for haskell templates.

pprQ :: (Functor m, Quasi m, Ppr a) => Q a -> m Doc Source #

Helper function for pretty printing `Q` Monad.

# Functions to print message or errors when compile time

Functions to display or to raise compile messages from codes which generating haskell templates.

Only messages directly generated by `Q` monad report actions are handled by ghc loggers.

    -- Handled by ghc logger
    qReport False "Foo"

    -- Not handled by ghc logger
    runIO . runQ $ qReport False "Foo"

reportWarning :: String -> Q () Source #

Print compile warnings from TH code.

reportError :: String -> Q () Source #

Print compile errors from TH code.