Unifying inferred and declared *existential* type variables

2014-08-16 Thread Dr. ERDI Gergo

Hi,

Background:

Type signatures for pattern synonyms are / can be explicit about the 
existentially-bound type variables of the pattern. For example, given the 
following definitions:


data T where
  C :: (Eq a) = [a] - (a, Bool) - T

pattern P x y = C x y

the inferred type of P (with explicit foralls printed) is

pattern type forall a. Eq a = P [a] (a, Bool) :: T


My problem:

Ticket #8968 is a good example of a situation where we need this 
pattern type signature to be entered by the user. So continuing with the 
previous example, the user should be able to write, e.g.


pattern type forall b. Eq b = P [b] (b, Bool) : T

So in this case, I have to unify the argument types [b] ~ [a] and (b, 
Bool) ~ (a, Bool), and then use the resulting coercions of the 
existentially-bound variables before calling the success continuation.


So I generate a pattern synonym matcher as such (going with the previous 
example) (I've pushed my code to wip/T8584):


 $mP{v r0} :: forall t [sk].
  T
  - (forall b [sk]. Eq b [sk] = [b [sk]] - (b [sk], Bool) - t [sk])
  - t [sk]
  - t [sk]
 $mP{v r0}
   = /\(@ t [sk]).
 \ ((scrut [lid] :: T))
   ((cont [lid] :: forall b [sk]. Eq b [sk] = [b [sk]] - (b [sk], Bool) 
- t [sk]))
   ((fail [lid] :: t [sk]))
   - case scrut
  of {
C {@ a [ssk] ($dEq_aCt [lid] :: Eq a [ssk]) EvBindsVaraCu}
  (x [lid] :: [a [ssk]])
  (y [lid] :: (a [ssk], Bool))
  - cont b $dEq_aCr x y
   | (cobox{v} [lid], Bool_N)_N
   | [cobox{v} [lid]]_N }
 }

The two 'cobox'es are the results of unifyType'ing [a] with [b] and (a, 
Bool) with (b, Bool). So basically what I hoped to do was to pattern-match 
on 'C{@ a $dEqA} x y' and pass that to cont as 'b' and '$dEqB' by 
rewriting them  with the coercions. (It's unfortunate that even with full 
-dppr-debug output, I can't see what's inside the 'cobox'es).


However, when I try doing this, I end up with the error message

SigGADT2.hs:10:9:
Couldn't match type ‘a [ssk]’ with ‘b [sk]’
  because type variable ‘b [sk]’ would escape its scope
This (rigid, skolem) type variable is bound by
  the type signature for
P :: [b [sk]] - (b [sk], Bool) - T
  at SigGADT2.hs:10:9
Expected type: [b [sk]]
  Actual type: [a [ssk]]

Also, while the result of unifying '[b]' ~ '[a]' and '(b, Bool)' ~
'(a, Bool)' should take care of turning the 'a' bound by the constructor 
into the 'b' expected by the continuation function, it seems to me I'll 
need to do some extra magic to also turn the bound 'Eq a' evidence 
variable into the 'Eq b'.


Obviously, I am missing a ton of stuff here. Can someone help me out?

Thanks,
Gergo

--

  .--= ULLA! =-.
   \ http://gergo.erdi.hu   \
`---= ge...@erdi.hu =---'
I love vegetarians - some of my favorite foods are vegetarians.___
ghc-devs mailing list
ghc-devs@haskell.org
http://www.haskell.org/mailman/listinfo/ghc-devs


Re: Moving Haddock *development* out of GHC tree

2014-08-16 Thread Mateusz Kowalczyk
On 08/15/2014 04:32 PM, Simon Peyton Jones wrote:
 Great. Please can what you do be documented clearly somewhere, with a link to 
 that documentation from here 
 https://ghc.haskell.org/trac/ghc/wiki/Repositories, and/or somewhere else 
 suitable?
 
 Thanks
 
 Simon
 

Nothing on that page needs to change. The only thing that needs
documenting is than any GHC dev pushing to Haddock needs to do so on the
‘ghc-head’ branch.

I have made a change to the table at [1] and added a note but perhaps
there's another place that I need to make a change at that's not
immediately obvious. Herbert kindly updated the sync-all script that
defaults to the new branch so I think we're covered. Please don't
hesitate to ask if you (plural) need help with something here.

[1]: https://ghc.haskell.org/trac/ghc/wiki/WorkingConventions/Git/Submodules


-- 
Mateusz K.
___
ghc-devs mailing list
ghc-devs@haskell.org
http://www.haskell.org/mailman/listinfo/ghc-devs


Re: Moving Haddock *development* out of GHC tree

2014-08-16 Thread Herbert Valerio Riedel
On 2014-08-16 at 16:59:51 +0200, Mateusz Kowalczyk wrote:

[...]

 Herbert kindly updated the sync-all script that
 defaults to the new branch so I think we're covered. 

Minor correction: I did not touch the sync-all script at all. I merely
declared a default branch in the .gitmodules file:

  
http://git.haskell.org/ghc.git/commitdiff/03a8003e5d3aec97b3a14b2d3c774aad43e0456e

___
ghc-devs mailing list
ghc-devs@haskell.org
http://www.haskell.org/mailman/listinfo/ghc-devs