[Haskell-cafe] Associated types
dave at zednenem.com
Thu Jul 1 14:22:12 EDT 2010
On Thu, Jul 1, 2010 at 2:09 PM, Andrew Coppin
<andrewcoppin at btinternet.com> 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...)
Something like this should work:
class (Path p, CompletePath (CompletedPath p)) => IncompletePath p where
type CompletedPath p :: *
Dave Menendez <dave at zednenem.com>
More information about the Haskell-Cafe