Currently the Uniques leak into the TH.NameU making Ord TH.Name
nondeterministic. This makes the microlens library generate
nondeterministic lenses because they keep TH.Names in a set
and then turn it into a list.
To fix it I've added an additional ordering key to NameU as
described in Note [Template Haskell name translation].
- refactors the reify step to make reifyName monadic giving access to the env
- extends NameU to hold an ordering key
- remembers the Unique -> ordering key mapping in TcGblEnv
- hooks a translation step in qNewName and reifyName
- adds a testcase that demonstrates the problem
This is a breaking change that will break at least:
There are some things I'm not sure about:
- is TcGblEnv really the best place to keep the state?
- do we need the same thing for NameL? I think we don't because these names are already stable
- this changes the TH library, do I need to document it somewhere?