From: Jerome Vouillon <Jerome.Vouillon@inria.fr>
To: Markus Mottl <mottl@miss.wu-wien.ac.at>, OCAML <caml-list@inria.fr>
Subject: Re: question on recursive types
Date: Mon, 22 Mar 1999 13:53:18 +0100 [thread overview]
Message-ID: <19990322135318.08356@pauillac.inria.fr> (raw)
In-Reply-To: <199903211947.UAA20606@miss.wu-wien.ac.at>; from Markus Mottl on Sun, Mar 21, 1999 at 08:47:55PM +0100
Hello,
On Sun, Mar 21, 1999 at 08:47:55PM +0100, Markus Mottl wrote:
> I am trying to find a useful approach for sending streams of messages
> to objects and have come across the following problem (code example):
>
> class transformer = object (self)
> method apply_strm s =
> try while true do (Stream.next s) self s done with Stream.Failure -> ()
> end
[...]
> Unfortunately, this results in a recursive type, because the elements of
> the stream are functions that have to accept the same type of streams
> as parameter.
[...]
The usual trick to avoid explicitely recursive types is to use a type
constructor:
type 'a t = Stream of ('a -> 'a t -> unit) Stream.t;;
class transformer = object (self)
method apply_strm s =
try
while true do (Stream.next s) self (Stream s) done
with Stream.Failure -> ()
end;;
-- Jérôme
prev parent reply other threads:[~1999-03-22 14:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-03-21 19:47 Markus Mottl
1999-03-22 12:53 ` Jerome Vouillon [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=19990322135318.08356@pauillac.inria.fr \
--to=jerome.vouillon@inria.fr \
--cc=caml-list@inria.fr \
--cc=mottl@miss.wu-wien.ac.at \
/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