Remove "smart" generic tuple handling
flupe opened this issue · comments
Currently we have a generic implementation of n
-uples in agda2hs.
That is, Tuple
is defined by large elimination over a list of types, so that we have a unified way of representing tuples of different lengths. While nice in theory, the only real benefit we get is easy definition of typeclass instances in the Haskell prelude.
But there are way too many downsides:
- The large-elimination definition was required to appease the positivity checker (#95, #96) but is cumbersome and leaky.
- We have to add many checks to ensure
Tuple
is always applied to a concrete list of types:agda2hs/src/Agda2Hs/Compile/Type.hs
Lines 41 to 70 in 57811ed
- We have to add special checks for tuple terms for the same reason:
agda2hs/src/Agda2Hs/Compile/Term.hs
Lines 54 to 67 in 57811ed
- Since Agda inlines let bindings entirely, using pattern-matching let bindings on tuples is currently buggy (#215) and we can really only easily fix it for 2-uples (#216).
- I don't think we support tuple sections, a quite useful and commonplace Haskell feature.
I hope these points convey properly that perhaps we should be pragmatic and have a simpler implementation for tuples. Let's remove all genericity and implement n
-uples separately for n
between 2 and I don't know, let's say, 5.