Infinite types
Jeffrey A. Scofield
jeff at dhitechnologies.com
Wed Dec 3 14:07:03 EST 2003
Greetings.
Say I have the following function, adapted from Pierce, Types and
Programming languages:
f n () = (n, f (n + 1))
Now, this function fails to typecheck in ghc 6.0.1 because the
subexpression f (n + 1) has the infinite type t = () -> (t1, t)
And so I assume (perhaps wrongly?) that f is ill-typed in Haskell 98.
I have two questions:
1. How can I tell from the Haskell 98 Revised Report that this
function isn't allowed? The discussions of typing in the Report
generally defer to the ``standard Hindley-Milner analysis.''
Is this really enough to tell that the function isn't well-typed
in Haskell? I concede that I haven't read the cited Hindley and
Damas/Milner papers, but it seems like there might be more to
say about what is and isn't allowed.
2. Is there by chance a compiler option for ghc that causes the
restriction to be dropped?
I don't need this kind of function for anything practical (and I
realize I can get an equivalent effect with an algebraic datatype).
I'm just trying to figure out what typing restrictions (if any) are
implicitly assumed in the Report. (Generally, this is the kind of
stuff I don't know, as a relative newcomer to fp.)
Regards,
Jeff Scofield (PhD)
Seattle
More information about the Haskell-Cafe
mailing list