From dd2af98d191d762e68e0b4c916096afad8b04dd7 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones <simonpj@microsoft.com> Date: Fri, 30 Mar 2012 12:51:14 +0100 Subject: [PATCH] Fix an egregious bug in the fingerprint calculation for TypeRep Given (T ty1) and ty2, we were computing the fingerprint of the application (T ty1 ty2) by combining the two fingerprints from (T ty1) and ty2. But that gives a different answer to combinging the three fingerprints from T, ty1, and ty2, which is what happens if you build the type all at once. Urk! Fixes Trac #5962 MERGED from commit f35ebbd5dfd108487efa7912349e9802f6029897 --- Data/Typeable/Internal.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Data/Typeable/Internal.hs b/Data/Typeable/Internal.hs index b5916e14..a89f43cd 100644 --- a/Data/Typeable/Internal.hs +++ b/Data/Typeable/Internal.hs @@ -157,9 +157,12 @@ funResultTy trFun trArg -- | Adds a TypeRep argument to a TypeRep. mkAppTy :: TypeRep -> TypeRep -> TypeRep -mkAppTy (TypeRep tr_k tc trs) arg_tr - = let (TypeRep arg_k _ _) = arg_tr - in TypeRep (fingerprintFingerprints [tr_k,arg_k]) tc (trs++[arg_tr]) +mkAppTy (TypeRep _ tc trs) arg_tr = mkTyConApp tc (trs ++ [arg_tr]) + -- Notice that we call mkTyConApp to construct the fingerprint from tc and + -- the arg fingerprints. Simply combining the current fingerprint with + -- the new one won't give the same answer, but of course we want to + -- ensure that a TypeRep of the same shape has the same fingerprint! + -- See Trac #5962 -- | Builds a 'TyCon' object representing a type constructor. An -- implementation of "Data.Typeable" should ensure that the following holds: -- GitLab