[Haskell-cafe] Lazy series [was : Preventing sharing]

Arjen arjenvanweelden at gmail.com
Sat Jan 9 18:22:48 UTC 2016



On 01/09/2016 07:11 PM, Tom Ellis wrote:
> On Sat, Jan 09, 2016 at 07:04:17PM +0100, Arjen wrote:
>> If I'm not mistaken, a strict language implies that arguments are
>> evaluated before function calls.  To calculate exps, you need to add 1 to
>> the result of the function call integral on argument exps.
>
> Sure, but why should evaluating exps actually do anything?  If exps is of
> function type then evaluating it need not do anything at all!
>
>> To evaluate that call, it first evaluates the arguments: exps.  And so
>> on...  This causes a non-terminating calculation, I would expect.
>
> I disagree, for the reason above.
>
>> IMHO, unless you add explicit laziness to a strict language, which
>> some do but it requires some extra syntax, this cannot be done.
>
> You don't even need explicit laziness.  Having exps be of function type will
> do.  That means evaluating it will terminate early.
>
>> If you propose that a function (or anything with a function type) is
>> implicitly lazy, then I think that you are describing a
>> lazy/non-strict language.
>
> I'm not sure what you're getting at here.  I'm not proposing that function
> application is evaluated lazily, I'm claiming that functions themselves are
> lazy datatypes since they contain computations that are only run when you
> applying them to arguments.
>
> Tom

I was thinking of exps as a value (having a non-function type). Maybe 
I'm wrong or just not understanding the issue fully. How do you 
differentiate between expression that are values and those that are 
function applications on arguments?

If I were to print the value of exps, like main = print exps. How would 
I express this? Or is it print's responsibility to evaluate the argument?
Say, exps has type Integer. How does print differentiate between a 
actual value (print 42) and unevaluated expressions (print exps)?

kind regards, Arjen


More information about the Haskell-Cafe mailing list