summaryrefslogtreecommitdiff
path: root/compiler/types/TyCon.hs
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2019-05-05 20:37:31 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-05-29 10:39:43 -0400
commit69b1633104a43d5654e65f2c05fa6b73775936e2 (patch)
tree42db5ac2468dc1b19f13616a397c45385258e5dc /compiler/types/TyCon.hs
parentf9d61ebbf4bba7862ae53c69b0f7116423b8f6d1 (diff)
downloadhaskell-69b1633104a43d5654e65f2c05fa6b73775936e2.tar.gz
Fix missing unboxed tuple RuntimeReps (#16565)
Unboxed tuples and sums take extra RuntimeRep arguments, which must be manually passed in a few places. This was not done in deSugar/Check. This error was hidden because zipping functions in TyCoRep ignored lists with mismatching length. This is now fixed; the lengths are now checked by calling zipEqual. As suggested in #16565, I moved checking for isTyVar and isCoVar to zipTyEnv and zipCoEnv.
Diffstat (limited to 'compiler/types/TyCon.hs')
-rw-r--r--compiler/types/TyCon.hs26
1 files changed, 20 insertions, 6 deletions
diff --git a/compiler/types/TyCon.hs b/compiler/types/TyCon.hs
index cdfcf181a5..54a57cfc45 100644
--- a/compiler/types/TyCon.hs
+++ b/compiler/types/TyCon.hs
@@ -358,13 +358,27 @@ Note [Unboxed tuple RuntimeRep vars]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The contents of an unboxed tuple may have any representation. Accordingly,
the kind of the unboxed tuple constructor is runtime-representation
-polymorphic. For example,
+polymorphic.
+
+Type constructor (2 kind arguments)
+ (#,#) :: forall (q :: RuntimeRep) (r :: RuntimeRep).
+ TYPE q -> TYPE r -> TYPE (TupleRep [q, r])
+Data constructor (4 type arguments)
+ (#,#) :: forall (q :: RuntimeRep) (r :: RuntimeRep)
+ (a :: TYPE q) (b :: TYPE r). a -> b -> (# a, b #)
+
+These extra tyvars (q and r) cause some delicate processing around tuples,
+where we need to manually insert RuntimeRep arguments.
+The same situation happens with unboxed sums: each alternative
+has its own RuntimeRep.
+For boxed tuples, there is no levity polymorphism, and therefore
+we add RuntimeReps only for the unboxed version.
+
+Type constructor (no kind arguments)
+ (,) :: Type -> Type -> Type
+Data constructor (2 type arguments)
+ (,) :: forall a b. a -> b -> (a, b)
- (#,#) :: forall (q :: RuntimeRep) (r :: RuntimeRep). TYPE q -> TYPE r -> #
-
-These extra tyvars (v and w) cause some delicate processing around tuples,
-where we used to be able to assume that the tycon arity and the
-datacon arity were the same.
Note [Injective type families]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~