th-desugar-1.13: Functions to desugar Template Haskell
Copyright(C) 2014 Richard Eisenberg
LicenseBSD-style (see LICENSE)
MaintainerRyan Scott
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Language.Haskell.TH.Desugar.Expand

Description

Expands type synonyms and type families in desugared types. See also the package th-expand-syns for doing this to non-desugared types.

Synopsis

Expand synonyms soundly

expand :: (DsMonad q, Data a) => a -> q a Source #

Expand all type synonyms and type families in the desugared abstract syntax tree provided, where type family simplification is on a "best effort" basis. Normally, the first parameter should have a type like DExp or DLetDec.

expandType :: DsMonad q => DType -> q DType Source #

Expands all type synonyms in a desugared type. Also expands open type family applications. (In GHCs before 7.10, this part does not work if there are any variables.) Attempts to expand closed type family applications, but aborts the moment it spots anything strange, like a nested type family application or type variable.

Expand synonyms potentially unsoundly

expandUnsoundly :: (DsMonad q, Data a) => a -> q a Source #

Expand all type synonyms and type families in the desugared abstract syntax tree provided, where type family simplification is on a "better than best effort" basis. This means that it will try so hard that it will sometimes do the wrong thing. Specifically, any kind parameters to type families are ignored. So, if we have

type family F (x :: k) where
  F (a :: *) = Int

expandUnsoundly will expand F 'True to Int, ignoring that the expansion should only work for type of kind *.

This function is useful because plain old expand will simply fail to expand type families that make use of kinds. Sometimes, the kinds are benign and we want to expand anyway. Use this function in that case.