Quantcast
Channel: Active questions tagged ocaml - Stack Overflow
Viewing all articles
Browse latest Browse all 531

Why is the output type bool in this OCaml fun?

$
0
0

I'm sure I'm missing something, but where is the bool?

let iter t ~f =   let rec loop !t  = function    |Some element -> ~f element.value; loop element.next    |None -> () 

Expecting unit, have bool in type of iter:

('a element option -> unit) ref -> f:('a -> 'b) -> bool

Also compared to this version

let iter t ~f =   let rec loop   = function    |Some element -> f element.value; loop element.next    |None -> () in loop !t

Why 'a element option ref vs. ('a element option -> unit)?


Viewing all articles
Browse latest Browse all 531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>