Hacker News new | ask | show | jobs
by paulbaumgart 5852 days ago
Interesting. I assumed Haskell would at least warn you. But it's probably only a matter of time before Catch is built in to the compiler, at least as an option.
1 comments

OCaml does warn you:

    : kragen@inexorable:~/mail ; ocaml
            Objective Caml version 3.10.2

    # let divide x = function 0 -> None | y -> Some (x / y) ;;
    val divide : int -> int -> int option = <fun>
    # let printResult = function Some x -> print_int x ;;  
    Warning P: this pattern-matching is not exhaustive.
    Here is an example of a value that is not matched:
    None
    val printResult : int option -> unit = <fun>
    # printResult (divide 9 3) ;;
    3- : unit = ()
    # printResult (divide 10 0) ;;
    Exception: Match_failure ("", 1, 18).
    #