Permalink
Browse files
Wibbles from Simon and Pedro
- Loading branch information...
|
@@ -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