caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Tom <tom.primozic@gmail.com>
Cc: Jon Harrop <jon@ffconsultancy.com>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Help me find this pdf
Date: Fri, 19 Oct 2007 10:59:59 +1000	[thread overview]
Message-ID: <1192755599.13520.34.camel@rosella.wigram> (raw)
In-Reply-To: <c1490a380710181307q547fe923xc73c99be2a5f6533@mail.gmail.com>


> On 18/10/2007, skaller <skaller@users.sourceforge.net> wrote:
>         
>         No, but Felix does it by default
> 
> What do you mean? You mean that if I write a map
> 
>    map f [] = []
>    map f x:xs = f x : map f xs
> 
> I can apply it both to infinite and lazy lists?

No, it means that when you write

	fun map[t] (f:t->u) (xs:list[t]) => ...

it is indeterminate whether f and/or xs are evaluated
before calling map (eager evaluation), or whether they're 
replaced by their arguments in the definition of map
(lazy evaluation). 

If the list itself is given by a formula, this means
the formula for the list may replace 'xs' in the map,
and only be evaluated when required. 

In particular the list may be enumerated eagerly
or lazily so it must be a list, not a stream,
or your program may fail to terminate.

In Felix a list is given by

	union list[t] = Empty | Cons of t * list[t];

and the combinators for | and * are eager, so all
inductive data types in Felix are eager. Only function
application has indeterminate timing.

I'm not sure I can fix this because, for example,
a product is just a C++ struct, and C++ operator. cannot
be overloaded. However operator->() and operator *() can
be overloaded, so it just might be possible to make
pattern matching lazy.

Thanks for asking this question .. forced me to think!



-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  reply	other threads:[~2007-10-19  1:03 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-18  9:52 Tom
2007-10-18 10:33 ` [Caml-list] " skaller
2007-10-18 11:01   ` Andreas Rossberg
2007-10-18 12:25 ` Jon Harrop
2007-10-18 12:40   ` Arnaud Spiwack
2007-10-18 13:17     ` Jon Harrop
2007-10-18 15:15       ` Till Varoquaux
2007-10-18 12:46   ` Jacques Garrigue
2007-10-18 13:57     ` Jon Harrop
2007-10-18 14:22       ` Brian Hurt
2007-10-18 14:52         ` Robert Fischer
2007-10-18 15:04           ` Eric Cooper
2007-10-18 17:18         ` Jon Harrop
2007-10-19  1:16           ` skaller
2007-10-19  5:09           ` Bárður Árantsson
2007-10-19  5:23             ` [Caml-list] " Erik de Castro Lopo
2007-10-19  5:46               ` Bárður Árantsson
2007-10-19 12:25               ` [Caml-list] " Christophe Raffalli
2007-10-19 12:47                 ` Luc Maranget
2007-10-20 14:26                   ` Christophe Raffalli
2007-10-19 14:48                 ` Robert Fischer
2007-10-19 21:43                   ` Andreas Rossberg
2007-10-19 21:51                     ` Robert Fischer
2007-10-20 13:10                       ` Andreas Rossberg
2007-10-19 23:10                     ` Jon Harrop
2007-10-20  1:13                       ` skaller
2007-10-20  6:36                         ` Tom
2007-10-21 11:17                           ` skaller
2007-10-19  8:55             ` Zheng Li
2007-10-19 22:27             ` [Caml-list] " Jon Harrop
2007-10-19 13:00           ` [Caml-list] " Brian Hurt
2007-10-19 13:49             ` Loup Vaillant
2007-10-19 14:41               ` Zheng Li
2007-10-19 23:09             ` [Caml-list] " Jon Harrop
2007-10-18 20:07   ` Tom
2007-10-19  0:59     ` skaller [this message]
2007-10-18 20:48 ` Lauri Alanko

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=1192755599.13520.34.camel@rosella.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@yquem.inria.fr \
    --cc=jon@ffconsultancy.com \
    --cc=tom.primozic@gmail.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;
as well as URLs for NNTP newsgroup(s).