From 360b076be98536a15a5feb14cc0089c9d246dd57 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 3 Dec 2008 17:30:57 +0000 Subject: [PATCH] Made genMapInstance and genSetInstance generate instances for the directly contained types --- polyplate/Data/Generics/Polyplate/GenInstances.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/polyplate/Data/Generics/Polyplate/GenInstances.hs b/polyplate/Data/Generics/Polyplate/GenInstances.hs index 4d084fb..6ef619b 100644 --- a/polyplate/Data/Generics/Polyplate/GenInstances.hs +++ b/polyplate/Data/Generics/Polyplate/GenInstances.hs @@ -92,6 +92,11 @@ instance Eq Witness where genMapInstance :: forall k v. (Ord k, Data k, Data v) => k -> v -> GenInstance genMapInstance k v = GenInstance $ do + -- Must find types for contained types, in case they are not generated elsewhere. + -- This is true for Tock, where NameDefs only exist in AST or CompState + -- in a Map. + findTypesIn k + findTypesIn v tk <- liftIO $ typeKey m modify (Map.insert tk (show $ typeOf m, Detailed (DataBox m) [DataBox k, DataBox v] $ \(funcSameType, funcNewType) -> @@ -109,6 +114,8 @@ genMapInstance k v genSetInstance :: forall a. (Ord a, Data a) => a -> GenInstance genSetInstance x = GenInstance $ do + -- Must find types for contained types, in case they are not generated elsewhere. + findTypesIn x tk <- liftIO $ typeKey s modify (Map.insert tk (show $ typeOf s, Detailed (DataBox s) [DataBox x] $ \(funcSameType, funcNewType) ->