Uniquable RdrName instance

Richard Eisenberg eir at cis.upenn.edu
Tue Jun 17 14:00:41 UTC 2014


So, without really trying to understand the code, what you are saying is this: you want a finite map from RdrNames. That seems sensible enough, if the domain elements all appear in the same scope in the Haskell source. I don't have enough perspective to say whether a Uniquable instance is the way to get to a finite map here.

Richard

On Jun 16, 2014, at 3:33 PM, Jan Stolarek <jan.stolarek at p.lodz.pl> wrote:

>> Why do you want this? The danger I see lurking is that you might find two
>> RdrNames that give the same answer to getUnique but represent different
> Yes, that's exactly my concern.
> 
>> Why do you want this?
> I'm working on #7282 - RebindableSyntax and Arrows. Here's a snippet from desugaring of arrow 
> notation:
> 
> leaves = concatMap leavesMatch matches
> where
>   leavesMatch :: LMatch Id (Located (body Id)) -> [(Located (body Id), IdSet)]
>   leavesMatch (L _ (Match pats _ (GRHSs grhss binds)))
>         = let defined_vars = mkVarSet (collectPatsBinders pats) `unionVarSet`
>                                          mkVarSet (collectLocalBinders binds)
>             in  [(body, mkVarSet (collectLStmtsBinders stmts) `unionVarSet` defined_vars) | L _ 
> (GRHS stmts body) <- grhss]
> 
> This is in the desugarer. But I need to also know `length leaves` at the renaming stage, which 
> means I need to call `concatMap leavesMatch matches`. The problem is that in the renamer my 
> datatypes are not parametrised by `Id`. I turned `Id` into a type parameter `id`, but then I 
> can't use VarSets. I could use more general UniqueSets but only if `id` type parameter is an 
> instance of Uniquable. And since in the renamer the datatypes are parametrized with RdrName this 
> leads me to wanting Uniqable RdrName instance.
> 
> Janek



More information about the ghc-devs mailing list