
Consider the following: class Path p where ... class Path p => CompletePath p where ... class Path p => IncompletePath p where type CompletedPath p :: * Obviously, the idea is that CompletedPath Foo (where Foo is an IncompletePath) should yield some type which is a CompletePath. However, the source code does not actually state this, so GHC (rightly) complains that it was unable to deduce this constraint from the actual code written. Is it possible to state this constraint? If so, how? (And if not, the answer, presumably, is to fundamentally redesign the whole thing...)

On Thu, Jul 1, 2010 at 2:09 PM, Andrew Coppin
Consider the following:
class Path p where ...
class Path p => CompletePath p where ...
class Path p => IncompletePath p where type CompletedPath p :: *
Obviously, the idea is that CompletedPath Foo (where Foo is an IncompletePath) should yield some type which is a CompletePath. However, the source code does not actually state this, so GHC (rightly) complains that it was unable to deduce this constraint from the actual code written.
Is it possible to state this constraint? If so, how? (And if not, the answer, presumably, is to fundamentally redesign the whole thing...)
Something like this should work:
class (Path p, CompletePath (CompletedPath p)) => IncompletePath p where
type CompletedPath p :: *
--
Dave Menendez

On Thu, 1 Jul 2010, Christopher Lane Hinson wrote:
Something like this should work:
class (Path p, CompletePath (CompletedPath p)) => IncompletePath p where type CompletedPath p :: *
AIUI, this isn't implemented yet. You'll have to place the constraint on each involved function.
Friendly, --Lane
I would have sworn I tested this in 6.12.x, but I'm wrong. It works. Isn't there something left unimplemented that I am thinking of? Tell me I'm not crazy! Weird, --Lane

On Thu, Jul 1, 2010 at 2:35 PM, Christopher Lane Hinson
On Thu, 1 Jul 2010, Christopher Lane Hinson wrote:
Something like this should work:
class (Path p, CompletePath (CompletedPath p)) => IncompletePath p where type CompletedPath p :: *
AIUI, this isn't implemented yet. You'll have to place the constraint on each involved function.
Friendly, --Lane
I would have sworn I tested this in 6.12.x, but I'm wrong. It works.
Isn't there something left unimplemented that I am thinking of? Tell me I'm not crazy!
Maybe you're thinking of equality superclasses. In another thread,
this example came up:
| class (DerivedOf a ~ derived) => Typecheck a derived where
which doesn't work yet, but should work in 6.14.
--
Dave Menendez

On 2 July 2010 04:48, David Menendez
Maybe you're thinking of equality superclasses. In another thread, this example came up:
| class (DerivedOf a ~ derived) => Typecheck a derived where
which doesn't work yet, but should work in 6.14.
I've asked Manuel Chakravarty about this, and he isn't sure if it will be ready in time for 6.14 :( -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

On Thu, Jul 1, 2010 at 2:26 PM, Christopher Lane Hinson < lane@downstairspeople.org> wrote:
class (Path p, CompletePath (CompletedPath p)) => IncompletePath p where
type CompletedPath p :: *
AIUI, this isn't implemented yet. You'll have to place the constraint on each involved function.
This much works. However equality constraints in the body still blow up at last check. -Edward Kmett

GADTs? data CompletePathEv p where CompletePathEv :: CompletePath p => CompletePathEv p class Path p => IncompletePath p where type CompletedPath p :: * completedPathEv :: CompletePathEv (CompletedPath p) Later you can pattern-match on completedPathEv and get your CompletePath instance back. On 1 Jul 2010, at 22:09, Andrew Coppin wrote:
Consider the following:
class Path p where ...
class Path p => CompletePath p where ...
class Path p => IncompletePath p where type CompletedPath p :: *
Obviously, the idea is that CompletedPath Foo (where Foo is an IncompletePath) should yield some type which is a CompletePath. However, the source code does not actually state this, so GHC (rightly) complains that it was unable to deduce this constraint from the actual code written.
Is it possible to state this constraint? If so, how? (And if not, the answer, presumably, is to fundamentally redesign the whole thing...)
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (6)
-
Andrew Coppin
-
Christopher Lane Hinson
-
David Menendez
-
Edward Kmett
-
Ivan Miljenovic
-
Miguel Mitrofanov