Commit 71f4f068 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Wibbles from Simon and Pedro

parent 4830c8c2
......@@ -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,13 +70,17 @@ 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
......@@ -84,14 +88,6 @@ data DerivStuff -- Please add this auxiliary stuff
-- 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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment