Thankfully for our purposes there's an escape hatch: the values we provide won't be evaluated, so they can be `undefined`, and the `TypeRep`s generated from these values are only used for determining whether two types are (intensionally) equal or different.
My solution was to define two new types, `Z` and `S a`, which can be used as peano numerals. We convert all of the distinct types in our JSON into distinct peano numeral types (`replaceTypes`), we generate `TypeRep` values for these numeral types (`getRep`), fabricate values of these types as arguments to the underlying library (`getVal`), then switch back all of the types which occur in the result (`restoreTypes`).
Very ugly, but it works, thanks to the wiggle room I had based on what these types and values would be used for.
Other projects have been even more icky, e.g. sending strings of auto-generated Haskell code through `runhaskell` [2] and throwing auto-generated template haskell into GHCi to see what sticks [3].
I don't recommend any of this for production code :)
[1] http://hackage.haskell.org/package/reduce-equations
[2] http://hackage.haskell.org/package/nix-eval
[3] http://chriswarbo.net/git/annotatedb/branches/master/annotat...
One of my bigger interests in Haskell right now is the Frames library but I've honestly been struggling with using and understanding Template Haskell to generate Types.
I haven't had a ton of time so it isn't all TH's fault either. I've also read the Template Haskell paper and the entire system seems well thought out, I suppose there just aren't enough practical tutorials I can mess about with until I understand.