Re: Infinite types

2003-12-08 Thread Jeffrey A. Scofield
Ken Shan wrote: > 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 > > d

Re: Infinite types

2003-12-08 Thread oleg
Jeffrey A. Scofield wrote: > Say I have the following function, adapted from Pierce, Types and > Programming languages: > > f n () = (n, f (n + 1)) But a simple modification seems to cures the problem: > newtype W = W (Int, () -> W) > > f n () = W (n, f (n + 1)) > > w2list (W (n,f)) = n:(w2l

Re: Preventing/handling space leaks

2003-12-08 Thread ajb
G'day all. Quoting Sven Panne <[EMAIL PROTECTED]>: > Granted, C++'s (copy) constructors, destructors and assignment operators make > some > things relatively easy compared to C, but the complexity of handling > exceptions > *correctly* makes things worse again: There is a famous article (I can't

Re: Infinite types

2003-12-08 Thread Jeffrey A. Scofield
Jeremy Shaw wrote: > There is a thread on comp.lang.functional that talks about why haskell > does not support recursive types: > > http://groups.google.com/groups?q=ocaml+rectypes&hl=en&lr=lang_en&ie=UTF-8&oe=UTF-8&safe=off&selm=8giqpt%24oee%241%40rivesaltes.inria.fr&rnum=1 > > (searching for '

Re: Preventing/handling space leaks

2003-12-08 Thread ketil+haskell
Sven Panne <[EMAIL PROTECTED]> writes: > [ Just one more mail and I promise to shut up on this topic... :-) ] Surely slamming C++ is on topic? :-) > Fergus Henderson wrote: >> [...] C does suffer from many of the same problems as C. But in C++, it is >> much easier to automate techniques like

Re: Infinite types

2003-12-08 Thread Ken Shan
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 ty

Re: Infinite types

2003-12-08 Thread Jeffrey A. Scofield
[EMAIL PROTECTED] wrote: > > Say I have the following function, ... : > > > > f n () = (n, f (n + 1)) > > ... > > 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 > > gener

Re: Preventing/handling space leaks

2003-12-08 Thread Sven Panne
[ Just one more mail and I promise to shut up on this topic... :-) ] Fergus Henderson wrote: [...] C does suffer from many of the same problems as C. But in C++, it is much easier to automate techniques like reference counting, which can be done manually in C but are much more cumbersome and erro