(* here is my stream *)
type 'a stream
= Nil
| Cons of 'a * (unit -> 'a stream)
(* the take function *)
let rec take n s =
if n <= 0
then []
else
match s with
| Nil -> []
| Cons (n, g) -> n :: (take (n - 1) (g ()))
(* the from function *)
let rec from n = Cons (n, fun () -> from (n + 1))
(* Fatal error: exception Stack_overflow !! *)
let ten = take 10 (from 2)
edit
When I run code on TryOCaml (ocamlpro.com), it show the error message:
Stack overflow during evaluation (looping recursion?).