Permalink
Browse files

Wibbles from Simon and Pedro

  • Loading branch information...
simonpj committed Oct 6, 2011
1 parent 4830c8c commit 71f4f0683534b9bdca8d479da65f68e69ce7d4d8
Showing with 10 additions and 11 deletions.
  1. +2 −2 compiler/typecheck/TcDeriv.lhs
  2. +5 −9 compiler/typecheck/TcGenDeriv.lhs
  3. +3 −0 compiler/types/Generics.lhs
@@ -1491,10 +1491,10 @@ genDerivStuff loc fix_env clas name tycon
| className clas `elem` typeableClassNames
= return (gen_Typeable_binds loc tycon, emptyBag)
- | classKey clas == genClassKey
+ | classKey clas == genClassKey -- Special case because monadic
= gen_Generic_binds tycon (nameModule name)
- | otherwise
+ | otherwise -- Non-monadic generators
= case assocMaybe gen_list (getUnique clas) of
Just gen_fn -> return (gen_fn loc tycon)
Nothing -> pprPanic "genDerivStuff: bad derived class" (ppr clas)
@@ -70,28 +70,24 @@ import Data.List ( partition, intersperse )
\begin{code}
type BagDerivStuff = Bag DerivStuff
-data DerivStuff -- Please add this auxiliary stuff
+data AuxBindSpec
= DerivCon2Tag TyCon -- The con2Tag for given TyCon
| DerivTag2Con TyCon -- ...ditto tag2Con
| DerivMaxTag TyCon -- ...and maxTag
+ deriving( Eq )
-- All these generate ZERO-BASED tag operations
-- I.e first constructor has tag 0
+data DerivStuff -- Please add this auxiliary stuff
+ = DerivAuxBind AuxBindSpec
+
-- Generics
| DerivTyCon TyCon -- New data types
| DerivFamInst TyCon -- New type family instances
-- New top-level auxiliary bindings
| DerivHsBind (LHsBind RdrName, LSig RdrName) -- Also used for SYB
| DerivInst (InstInfo RdrName) -- New, auxiliary instances
-
-isDupAux :: DerivStuff -> DerivStuff -> Bool
-isDupAux (DerivCon2Tag tc1) (DerivCon2Tag tc2) = tc1 == tc2
-isDupAux (DerivTag2Con tc1) (DerivTag2Con tc2) = tc1 == tc2
-isDupAux (DerivMaxTag tc1) (DerivMaxTag tc2) = tc1 == tc2
-isDupAux (DerivTyCon tc1) (DerivTyCon tc2) = tc1 == tc2
-isDupAux (DerivFamInst tc1) (DerivFamInst tc2) = tc1 == tc2
-isDupAux _ _ = False
\end{code}
@@ -2,6 +2,9 @@
% (c) The University of Glasgow 2011
%
+The deriving code for the Generic class
+(equivalent to the code in TcGenDeriv, for other classes)
+
\begin{code}
module Generics ( canDoGenerics,

0 comments on commit 71f4f06

Please sign in to comment.