composite-base-0.4.0.0: Shared utilities for composite-* packages.

Safe HaskellNone
LanguageHaskell2010

Composite.TH

Synopsis

Documentation

withProxies :: Q [Dec] -> Q [Dec] Source #

Make Proxy definitions for each of the type synonyms in the given block of declarations. The proxies have the same names as the synonyms but with the first letter lowercased.

For example:

  withProxies [d|
    type FFoo = "foo" :-> Int
    |]

Is equivalent to:

  type FFoo = "foo" :-> Int
  fFoo :: Proxy FFoo
  fFoo = Proxy

Note: the trailing |] of the quasi quote bracket has to be indented or a parse error will occur.

withLensesAndProxies :: Q [Dec] -> Q [Dec] Source #

Make rlens and Proxy definitions for each of the type synonyms in the given block of declarations. The lenses have the same names as the synonyms but with the first letter lowercased. The proxies have that name but with _ suffix.

For example:

  withLensesAndProxies [d|
    type FFoo = "foo" :-> Int
    |]

Is equivalent to:

  type FFoo = "foo" :-> Int
  fFoo :: RElem FFoo rs (RIndex FFoo rs) => Lens' (Record rs) Int
  fFoo = rlens fFoo_
  fFoo_ :: Proxy FFoo
  fFoo_ = Proxy

Note: the trailing |] of the quasi quote bracket has to be indented or a parse error will occur.