From: Andrej Bauer <Andrej.Bauer@fmf.uni-lj.si>
To: Jon Harrop <jon@ffconsultancy.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Lazy.force
Date: Wed, 03 Jan 2007 09:46:11 +0100 [thread overview]
Message-ID: <459B6D53.7050109@fmf.uni-lj.si> (raw)
In-Reply-To: <200701022221.11975.jon@ffconsultancy.com>
Jon Harrop wrote:
> Could the type checker automatically insert Lazy.force whenever a lazy
> expression is used as an eager expression?
Consider:
let rec repeat n x =
if n = 0 then [] else x :: (repeat (n-1) x)
let rec sum = function [] -> 0 | x::xs -> x + sum xs
let cow = sum (repeat 1000 (lazy 3))
The typechecker will determine that
repeat : int -> 'a -> 'a list
sum : int list -> int
In the definition of cow it will see that sum, which expects int list,
is applied to int lazy_t list. Where and how should the compiler insert
Lazy.force in this example? Note that it cannot insert anything in the
definition of sum, because later on it might see
let chicken = sum [1;2;3;4]
Best regards,
Andrej
prev parent reply other threads:[~2007-01-03 8:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-02 22:21 Lazy.force Jon Harrop
2007-01-03 8:46 ` Andrej Bauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=459B6D53.7050109@fmf.uni-lj.si \
--to=andrej.bauer@fmf.uni-lj.si \
--cc=Andrej.Bauer@andrej.com \
--cc=caml-list@yquem.inria.fr \
--cc=jon@ffconsultancy.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox