how to know if a value has already been evaluated?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

how to know if a value has already been evaluated?

Ut Primum
In Haskell, the value of a variable is not always evaluated.
This is fundamental when working with infinite lists.
Is there a way of determining whether, at a certain point of the execution of a program, a value has been calculated or not?

In particular, I would like to write a function that works on an infinite list that:
- if the first value of a list, x, has already been evaluated, returns [x]
- Else waits until it is evaluated, but without forcing its evaluation. (eventually, its evaluation will be forced later by other functions). Until then, the result of this function must be considered as [ ]. As soon as x is computed, it can return [x].

Is something like this possible in Haskell?

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: how to know if a value has already been evaluated?

GUO Xing
Sounds like an *await* expression ...

I am curious about it too!

Regards
Xing
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners