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

Why my little monad in OCaml doesn't compile?

$
0
0

I'm learning Monad in OCaml, but it doesn't compile.

I reduced the code to reproduce the problem at easiest way :

file try.ml:

module type TRY = sig  type 'a t  val return : 'a -> 'a tendmodule Try : TRY = struct  type 'a t = Success of 'a | Failure of exn  let return a = Success aendlet () =  match Try.return 5 with  | Try.Success a -> print_int a  | Try.Failure e -> print_endline (Printexc.to_string e)

then I compile with :

ocamlc try.ml

and i get this error :

Error: Unbound constructor Try.Success

I found nowhere a clue to repair, I need help.


Viewing all articles
Browse latest Browse all 531

Trending Articles



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