diff options
author | Ian Lynagh <igloo@earth.li> | 2008-03-30 18:28:13 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2008-03-30 18:28:13 +0000 |
commit | ab5c770bed51f08d56a0d61086988053b21aa461 (patch) | |
tree | 56db1d5d73662627cd0c61bf556de661274e2c36 | |
parent | 6e93da5e0a775b2bfb9c9f2bd31a36cc828521cb (diff) | |
download | haskell-ab5c770bed51f08d56a0d61086988053b21aa461.tar.gz |
Derive a valid Ix instance for data Foo = Foo Int Int
The old one didn't satisfy the axioms. See trac #2158 for details.
-rw-r--r-- | compiler/typecheck/TcGenDeriv.lhs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/typecheck/TcGenDeriv.lhs b/compiler/typecheck/TcGenDeriv.lhs index 6d9fc55e59..f248674586 100644 --- a/compiler/typecheck/TcGenDeriv.lhs +++ b/compiler/typecheck/TcGenDeriv.lhs @@ -730,7 +730,11 @@ gen_Ix_binds tycon = mk_easy_FunBind tycon_loc unsafeIndex_RDR [nlTuplePat [con_pat as_needed, con_pat bs_needed] Boxed, con_pat cs_needed] - (mk_index (zip3 as_needed bs_needed cs_needed)) + -- We need to reverse the order we consider the components in + -- so that + -- range (l,u) !! index (l,u) i == i -- when i is in range + -- (from http://haskell.org/onlinereport/ix.html) holds. + (mk_index (reverse $ zip3 as_needed bs_needed cs_needed)) where -- index (l1,u1) i1 + rangeSize (l1,u1) * (index (l2,u2) i2 + ...) mk_index [] = nlHsIntLit 0 |