Re: Getting valid substitutions to work for subsumption

2017-05-18 Thread Richard Eisenberg
> On May 18, 2017, at 5:27 PM, Simon Peyton Jones wrote: > > I don't agree. If you call (tcSubsumes hole_ty ty) with closed types > hole_ty, ty, it should return True if I agree here. But it looks like Matthías's function gets the expected type as pushed down by

Re: Type class instances in scope

2017-05-18 Thread Edward Z. Yang
Hi Tom, The problem is that GHC lazily loads non-orphan instances, so they won't be in the environment until you load the interface which would have caused the instance to come into scope. I'm not sure exactly what you are actually trying to do. But if you really need all instances, you will

RE: Getting valid substitutions to work for subsumption

2017-05-18 Thread Simon Peyton Jones via ghc-devs
| This is going to be challenging to fix, I'm afraid. I don't agree. If you call (tcSubsumes hole_ty ty) with closed types hole_ty, ty, it should return True if ty is more polymorphic than hole_ty. For example tcSubsumes (forall a. [a] -> [a]) (forall b. b -> b) should

Type class instances in scope

2017-05-18 Thread Tom Sydney Kerckhove
Dear GHC Devs. I am trying to use the GHC API as part of the work that I am doing for my thesis. Currently I am looking for a way to find all the type class instances that are in scope in a given module. Here's what I've tried: ``` getInstancesFromTcmodule :: GhcMonad m =>

Re: Getting valid substitutions to work for subsumption

2017-05-18 Thread Richard Eisenberg
Hi Matthías, This is going to be challenging to fix, I'm afraid. When GHC sees a definition with a polymorphic type signature, it *skolemizes* the signature before ever looking at the definition. In this context, skolemizing means that GHC will fix the type variable a (in your trace, it

Getting valid substitutions to work for subsumption

2017-05-18 Thread Matthías Páll Gissurarson
Greetings, I'm working on improving the valid substitution feature that I implemented a few weeks ago, but I'm having a problem making it work with subsumption, i.e. if the types are not exactly equal. You can find all the code on a branch on my fork of GHC on GitHub

RE: Type families and classes

2017-05-18 Thread Simon Peyton Jones via ghc-devs
Yes that looks right. A class instance can’t dispatch on a type family application. In haskell we don’t allow reverse (a ++ b) = reverse a ++ reverse b and it’s the same for type families and class instances. You should do the type-family reduction yourself, as you do below. Simon From:

Re: Type families and classes

2017-05-18 Thread Alan & Kim Zimmerman
And to answer my own question, it seems instance HasSourceText SourceText where noSourceText= NoSourceText sourceText s= SourceText s getSourceText a = a And then applying the appropriate constraint at the use-site does the job. So noSyntaxExpr :: (HasSourceText (XHsString

Type families and classes

2017-05-18 Thread Alan & Kim Zimmerman
Hi all I am experimenting with Trees that Grow [1] in the context of the GHC HsSyn AST, and wanting to express that a given extension point needs to have certain properties. The specific case is to be able to contain a SourceText, in the context of HsLit So I have (stripped down) data GHCX