git.iko.soy/distributed-process
on master help sign in
Use FQN for functionSDict and functionTDict

This closes #41.

commit2a67728cbc7f40597d528bdefdcb346bfc7a29f4 authorEdsko de Vries <edsko@edsko.net> dateFri 5 Oct 2012, 09:43 (14 years ago) parentcb3afe0
1 file changed+16−4
distributed-process/src/Control/Distributed/Process/Internal/Closure/TH.hs+16−4
distributed-process/src/Control/Distributed/Process/Internal/Closure/TH.hs+16−4
@@ -16,6 +16,8 @@ import Language.Haskell.TH
1616 ( -- Q monad and operations
1717 Q
1818 , reify
19+ , Loc(loc_module)
20+ , location
1921 -- Names
2022 , Name
2123 , mkName
@@ -192,7 +194,7 @@ generateDefs (origName, fullType) = do
192194 [] -> [| toDynamic $(varE origName) |]
193195 _ -> [| toDynamic ($(varE origName) :: $(monomorphize typVars typ)) |]
194196 return ( static
195− , [ [| registerStatic $(stringE (show origName)) $dyn |] ]
197+ , [ [| registerStatic $(showFQN origName) $dyn |] ]
196198 )
197199
198200 makeDict :: Name -> Type -> Q ([Dec], [Q Exp])
@@ -200,7 +202,7 @@ generateDefs (origName, fullType) = do
200202 sdict <- generateDict dictName typ
201203 let dyn = [| toDynamic (SerializableDict :: SerializableDict $(return typ)) |]
202204 return ( sdict
203− , [ [| registerStatic $(stringE (show dictName)) $dyn |] ]
205+ , [ [| registerStatic $(showFQN dictName) $dyn |] ]
204206 )
205207
206208-- | Turn a polymorphic type into a monomorphic type using ANY and co
@@ -238,7 +240,7 @@ generateStatic n xs typ = do
238240 (map typeable xs)
239241 (staticTyp `AppT` typ)
240242 )
241− , sfnD (staticName n) [| staticLabel $(stringE (show n)) |]
243+ , sfnD (staticName n) [| staticLabel $(showFQN n) |]
242244 ]
243245 where
244246 typeable :: TyVarBndr -> Pred
@@ -249,7 +251,7 @@ generateDict :: Name -> Type -> Q [Dec]
249251generateDict n typ = do
250252 sequence
251253 [ sigD n $ [t| Static (SerializableDict $(return typ)) |]
252− , sfnD n [| staticLabel $(stringE (show n)) |]
254+ , sfnD n [| staticLabel $(showFQN n) |]
253255 ]
254256
255257staticName :: Name -> Name
@@ -291,3 +293,13 @@ sfnD n e = funD n [clause [] (normalB e) []]
291293tyVarBndrName :: TyVarBndr -> Name
292294tyVarBndrName (PlainTV n) = n
293295tyVarBndrName (KindedTV n _) = n
296+
297+-- | Fully qualified name; that is, the name and the _current_ module
298+--
299+-- We ignore the module part of the Name argument (which may or may not exist)
300+-- because we construct various names (`staticName`, `sdictName`, `tdictName`)
301+-- and those names certainly won't have Module components.
302+showFQN :: Name -> Q Exp
303+showFQN n = do
304+ loc <- location
305+ stringE (loc_module loc ++ "." ++ nameBase n)