Safe Haskell | None |
---|---|

Language | Haskell2010 |

The `Expanded`

class helps keep track of which `Type`

values have
been fully expanded to a canonical form. This lets us use the `Eq`

and `Ord`

relationships on `Type`

and `Pred`

values when reasoning
about instance context. What the `expandType`

function does is use
the function from `th-desugar`

to replace occurrences of `ConT name`

with the associated `Type`

if `name`

is a declared type synonym
`TySynD name _ typ`

. For convenience, a wrapper type `E`

is
provided, along with the `Expanded`

instances `E Type`

and ```
E
Pred
```

. Now the `expandType`

and `expandPred`

functions can be used
to return values of type `E Type`

and `E Pred`

respectively.

Instances `Expanded Type Type`

and `Expanded Pred Pred`

are
provided in Language.Haskell.TH.Context.Unsafe, for when less
type safety is required.

- newtype E a = E {
- _unE :: a

- unE :: forall a a. Iso (E a) (E a) a a
- type ExpandMap = Map Type (E Type)
- expandType :: (DsMonad m, MonadStates ExpandMap m) => Type -> m (E Type)
- expandPred :: (DsMonad m, MonadStates ExpandMap m) => Type -> m (E Type)
- expandClassP :: forall m. (DsMonad m, MonadStates ExpandMap m) => Name -> [Type] -> m (E Type)
- pprint1 :: (Ppr a, Data a) => a -> [Char]

# Documentation

A concrete type used to mark type which have been expanded

expandType :: (DsMonad m, MonadStates ExpandMap m) => Type -> m (E Type) Source #

Apply the th-desugar expand function to a `Type`

and mark it as expanded.

expandPred :: (DsMonad m, MonadStates ExpandMap m) => Type -> m (E Type) Source #

expandClassP :: forall m. (DsMonad m, MonadStates ExpandMap m) => Name -> [Type] -> m (E Type) Source #