[Haskell-cafe] Re: Wikipedia on first-class object

Cristian Baboi cristi at ot.onrc.ro
Mon Dec 31 02:11:12 EST 2007

Thank you.

data Something = This | S Something

ppp :: Something -> String

ppp This = ""
ppp (S x) = 'S':(ppp x)

How can I prevent one to pass  'let x = S x in x' to ppp ?

On Sun, 30 Dec 2007 23:25:19 +0200, Chaddaï Fouché  
<chaddai.fouche at gmail.com> wrote:

> 2007/12/30, Chaddaï Fouché <chaddai.fouche at gmail.com>:
>> 2007/12/30, Cristian Baboi <cristian.baboi at gmail.com>:
>> > A simple question:
>> >
>> > Can you write the value of x to a file where x = (1:x) ?
>> Yes, but you'll have to write it yourself, because Haskell can't
>> decide by itself that this value is infinite and try to print it with
>> a recursive definition, if it could do that, it could decide the
>> halting problem and that's not possible.
> Sorry, I'll try to be more precise since Cristian is pretty sticky
> with details when he can use them in its sense...
> In the particular case of x = (1:x), it can be detected that the
> structure is circular in memory and so infinite, but in the general
> case (for example if you replace (1:x) by (1:f x)) it can't be decided
> if the value is finite or infinite. You can't do a printer that do
> what you want in Haskell itself but you could probably do it with a VM
> or with compiler support, but it would be extremely tricky, also it
> would _always_ use the "running" form, even if this form isn't the
> optimal for storage (for example a filter of a huge list that results
> in an empty list would take enormously more place than with a normal
> printer).

________ Information from NOD32 ________
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
  part000.txt - is OK

More information about the Haskell-Cafe mailing list