ghci :browse! and type of class methods ([GHC] #1617)
Claus Reinke
claus.reinke at talk21.com
Thu Sep 6 09:04:13 EDT 2007
> About the it/output thing, I don't know. Can you be more explicit
> about what your question is?
i was worried about using a different method of implementing what
seemed to be the same thing. Simon M cleared up that 'it' is slightly
more complex, due to type dependencies.
> Concerning class methods...
>
> | *Main> :b! Control.Monad
> | fail :: Monad m -> forall a. String -> m a
>
> I can't explain why this does not print as (Monad m) => ...
> I'll try applying your patch when I have a clean build to hand.
thanks, that is my main question about this part. perhaps
i'm just using the wrong printTyThing variant? or there is
a variant missing in the GHC API.
> | class C a where c :: (Num b) => a -> b
> | c :: C a -> forall b. (Num b) => a -> b
>
> I think the right thing here is to change Type.dropForAlls,
> so that it drops for-alls nested to the right of arrows. Then
> you'd get c :: (C a, Num b) => a -> b
yes, that makes sense. but i'm wary of those type-manipulating
functions, as they only operate on the structure of the types,
not seeming to look at scopes. what if the inner forall shadows
a type variable binding from the outer forall? or, if i want to
lift the inner forall outwards, what if the inner forall captures
a type variable in the context? do i really have to do all this
myself, just to print out the type associated with a name?
> | class C a where c :: forall b. (Num b) => a -> b
> | c :: forall a. (C a) => forall b. (Num b) => a -> b
>
> This *really is* c's type, so it's only honest to say so.
shouldn't the correct type be something that would be
valid source code as well?
c :: forall a, b. (C a, Num b) => a -> b
the type shouldn't distinguish between class methods and
other overloaded functions, should it?
> (I'm not sure why -fglasgow-exts switches on
> forall-printing; that seems odd.
i'm only following :browse behaviour (comments say
that foralls are printed when the flags would allow them
to be used in source).
claus
More information about the Glasgow-haskell-bugs
mailing list