[Haskell-cafe] Associated types
miguelimo38 at yandex.ru
Thu Jul 1 14:38:49 EDT 2010
data CompletePathEv p where CompletePathEv :: CompletePath 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
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe