[Haskell-cafe] Non-termination due to context
Ross Paterson
ross at soi.city.ac.uk
Fri Jan 22 06:37:11 EST 2010
On Fri, Jan 22, 2010 at 12:24:37PM +0100, Emil Axelsson wrote:
> Consider the following program:
>
> >{-# LANGUAGE FlexibleInstances, OverlappingInstances, UndecidableInstances #-}
> >class B a => A a
> >
> >instance A Int
> >
> >class Eq a => B a
> >
> >instance (A a, Eq a) => B a
> [...]
> Although I don't know all the details of the class system, it seems
> unintuitive that I can make a program non-terminating just by
> changing the context of a function (regardless of
> UndecidableInstances etc.).
>
> Is this a bug or a feature?
I'm afraid you voided the warranty when you used UndecidableInstances.
You really do have a circularity between A and B here, so it's not
surprising that you get a loop. By changing the context, you demanded
more instances, undecidable ones in fact.
More information about the Haskell-Cafe
mailing list