composite-base-0.7.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 :: 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.

This is equivalent to withOpticsAndProxies but without the prisms.

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

Make fieldValPrism and Proxy definitions for each of the type synonyms in the given block of declarations. The prisms have the same names as the synonyms but prefixed with _. The proxies will have the same name as the synonym but with the first character lowercased and _ appended.

For example:

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

Is equivalent to:

  type FFoo = "foo" :-> Int
  _FFoo :: FFoo ∈ rs => Prism' (Field rs) Int
  _FFoo = fieldValPrism fFoo_
  fFoo_ :: Proxy FFoo
  fFoo_ = Proxy

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

This is equivalent to withOpticsAndProxies but without the prisms.

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

Make rlens, fieldValPrism, 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, e.g. FFoo becomes fFoo. The prisms have the same names as the synonyms but with _ prepended, e.g. FFoo becomes _FFoo. The proxies have the same names as the synonyms but with the first letter lowercase and trailing _, e.g. FFoo becomes fFoo_.

For example:

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

Is equivalent to:

  type FFoo = "foo" :-> Int
  fFoo :: FFoo ∈ rs => Lens' (Record rs) Int
  fFoo = rlens fFoo_
  _FFoo :: FFoo ∈ rs => Prism' (Field rs) Int
  _FFoo = fieldValPrism fFoo_
  fFoo_ :: Proxy FFoo
  fFoo_ = Proxy

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