caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] recursive records
@ 2013-11-08 20:10 Brigitte Pientka
  2013-11-08 20:17 ` Andreas Rossberg
  2013-11-09  4:02 ` oleg
  0 siblings, 2 replies; 5+ messages in thread
From: Brigitte Pientka @ 2013-11-08 20:10 UTC (permalink / raw)
  To: caml-list

I am playing around with using recursive records to define observations about
streams simulating essentially the ideas described in "Copatterns:Programming infinite structures by observations" presented at POPL'13.

type 'a susp = Susp of (unit -> 'a)

type 'a str = {hd: 'a  ; tl : ('a str) susp}

let rec ones = {hd = 1 ; tl = Susp (fun () -> ones)}

This works fine and many examples can be elegantly written this way.  However,
when I define the stream ones via the function delay, OCaml fails.

  let delay f = Susp f

  let rec ones = {hd = 1 ; tl = delay (fun () -> ones)};;
Characters 15-53:
   let rec ones = {hd = 1 ; tl = delay (fun () -> ones)};;
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This kind of expression is not allowed as right-hand side of `let rec'

Could someone explain why this fails?

Thanks, Brigitte


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-11-13  8:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-08 20:10 [Caml-list] recursive records Brigitte Pientka
2013-11-08 20:17 ` Andreas Rossberg
2013-11-08 21:56   ` Alain Frisch
2013-11-09  4:02 ` oleg
2013-11-13  8:01   ` Arkady Andrukonis

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).