Infinite types

Ken Shan ken at digitas.harvard.edu
Mon Dec 8 16:00:22 EST 2003


On 2003-12-08T12:42:46-0800, Jeffrey A. Scofield wrote:
>     b = () -> (a, b)
> [...]
> I'm wondering how to tell, as a relative newcomer to
> Haskell, that they aren't allowed.

I think the rule you're looking for is the following: Don't equate a
type variable with something that contains that type variable.  This
is known as the "occurs check".  This rule prohibits "equi-recursive"
types like "b" above, but not "iso-recursive" types like

    data List a = Nil | Cons a (List a)

because the type "List a" is merely isomorphic to something containing
"List a", but not equal to it.

-- 
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
International Human Rights Day * 2003-12-10 * http://www.un.org/rights/

What if All Chemists Went on Strike? (science fiction)
http://www.iupac.org/publications/ci/2003/2506/iw3_letters.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://haskell.org/pipermail/haskell-cafe/attachments/20031208/dd596b93/attachment.bin


More information about the Haskell-Cafe mailing list