Dear Pedro,

On 13 May 2012, at 20:29, José Pedro Magalhães wrote:
> On Fri, May 11, 2012 at 5:12 PM, "Philip K. F. Hölzenspies" 
> <p...@st-andrews.ac.uk> wrote:
> 
> However, it turns out that this never leads to an evaluation of 
> extTyNamesLoc. I've come as far as to see that, since "Located a" is a 
> synonym for "GenLocated SrcSpan a", the type we're looking for really has a 
> binary constructor, thus we should use ext2Q.
> 
> This made things work: We first modify the function we apply to Located 
> things:
> 
> 
> extTyNamesLoc :: (Data loc, Data a) => SrcSpan -> GenLocated loc a -> 
> OccurrenceTable
> extTyNamesLoc l (L l' x) = case cast l' of
>       Just l'' -> extTyNames l'' x
>       Nothing -> extTyNames l x
> 
> Do you really need this? Can't you use the definition of `extTyNamesLoc` 
> shown previously, and redefine `extTyNames` to use `ext2Q`, as in:

As it turns out, yes I do. You had me doubting whether I had tried this, but 
doing such a thing gives me:


refact.hs:124:72:
    Could not deduce (d1 ~ SrcSpan)
    from the context (Data a)
      bound by the type signature for
                 extTyNames :: Data a => SrcSpan -> RefCtx -> a -> OccTab
      at refact.hs:124:1-91
    or from (Data d1, Data d2)
      bound by a type expected by the context:
                 (Data d1, Data d2) => GenLocated d1 d2 -> OccTab
      at refact.hs:124:21-88
      `d1' is a rigid type variable bound by
           a type expected by the context:
             (Data d1, Data d2) => GenLocated d1 d2 -> OccTab
           at refact.hs:124:21
    Expected type: GenLocated d1 d2 -> OccTab
      Actual type: Located d2 -> OccTab
    In the return type of a call of `extTyNamesLoc'
    In the second argument of `ext2Q', namely `extTyNamesLoc l r'


Which makes a certain amount of sense. The use of ext2Q binds d1 and d2 to be 
restricted to Data, but otherwise unspecific. This seems at odds with the 
intention of extXY, hence my confusion.

I have since found and come to understand extB, though. This makes the 
implementation of extTyNamesLoc much, much nicer. However, I still think 
finding a good explanation for the behaviour of ext1Q/ext2Q could lead to a 
helpful addendum of the SYB documentation.

Regards,
Philip
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to