Skip to content

Commit

Permalink
Wibbles from Simon and Pedro
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Peyton Jones committed Oct 6, 2011
1 parent 4830c8c commit 71f4f06
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions compiler/typecheck/TcDeriv.lhs
Expand Up @@ -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)
Expand Down
14 changes: 5 additions & 9 deletions compiler/typecheck/TcGenDeriv.lhs
Expand Up @@ -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}


Expand Down
3 changes: 3 additions & 0 deletions compiler/types/Generics.lhs
Expand Up @@ -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,
Expand Down

0 comments on commit 71f4f06

Please sign in to comment.