GHC: Ticket Query
http://ghc.haskell.org/trac/ghc/query?status=!closed&reporter=lilac&order=priority
The Glasgow Haskell Compileren-USGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.png
http://ghc.haskell.org/trac/ghc/query?status=!closed&reporter=lilac&order=priority
Trac 1.0.1
http://ghc.haskell.org/trac/ghc/ticket/4259
http://ghc.haskell.org/trac/ghc/ticket/4259#4259: Relax restrictions on type family instance overlapMon, 16 Aug 2010 14:43:56 GMTlilac<p>
The following reduced fragment of some real code is rejected, but could be accepted, by GHC:
</p>
<pre class="wiki">{-# LANGUAGE TypeFamilies, EmptyDataDecls #-}
data True
type family LessEq a b :: *
type instance LessEq a a = True
type instance LessEq (f a) (f b) = LessEq a b
</pre><p>
GHC says:
</p>
<pre class="wiki"> Conflicting family instance declarations:
type instance LessEq a a
-- Defined at /home/richards/.random/tf.hs:5:14-19
type instance LessEq (f a) (f b)
-- Defined at /home/richards/.random/tf.hs:6:14-19
</pre><p>
This is entirely in line with the documentation, which requires the RHS to be structurally equivalent in the case of overlap. However, this rule is too restrictive. In the absence of -XUndecidableInstances, neither termination nor soundness would be sacrificed if the rule were relaxed to require extensional equality /after/ expanding the types as far as possible.
</p>
<p>
In particular (absent -XUndecidableInstances), such an expansion must terminate for the same reason that type families terminate in general. For soundness, suppose the resulting system is unsound, and consider the smallest type family application which has two possible distinct expanded types. We know the RHS of those types are equal after a partial expansion of only smaller (hence sound by minimality) type family applications, resulting in a contradiction.
</p>
<p>
In order to retain soundness in the presence of -XUndecidableInstances, any pair of type instances, where either instance could not be compiled without -XUndecidableInstances, would continue to use the current syntactic equality rule.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/4259#changelog
http://ghc.haskell.org/trac/ghc/ticket/3766
http://ghc.haskell.org/trac/ghc/ticket/3766#3766: Parsing of lambdas is not consistent with Haskell'98 report.Wed, 16 Dec 2009 16:05:09 GMTlilac<p>
Consider the following expression:
</p>
<p>
<tt> (\x -> x :: Int . id)</tt>
</p>
<p>
GHC (without any -X flags) currently reports a parse error:
</p>
<blockquote>
<p>
Illegal operator <tt>.' in type </tt>Int . id'<br /> Use -XTypeOperators to allow operators in types
</p>
</blockquote>
<p>
However, I think this expression is legal in Haskell'98 (and indeed still legal in Haskell 2010). The report gives an (ambiguous) expression grammar, which (unambiguously) parses the above as (\x -> (x :: Int)) . id. The report further says that lambdas extend as far as possible to the right, but the parse which GHC is using is not a possible parse according to the grammar, since infix operators (other than "->") are not allowed in the construction 'type'.
</p>
<p>
That said, I'd much rather see this fixed in the Haskell 2011 report than in GHC :)
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/3766#changelog