News for hackers. Stuff that matters.
Re:Pitfalls in Haskell by more_original on Monday August 22, 2016 @06:07AM (#12335213)
Incedentally, OCaml gets some of these right.

Record update in constructors is statically checked:

   type myData = MyData1 of { name : string } | MyData2 of { value : int }
   
   let x = MyData1 { name = "hello" }
   (* 
    * rejected:
    * let y = MyData2 { x with value = 0 }
    *)
   let y = match x with
           | MyData1 z -> failwith "todo"
           | MyData2 z -> MyData2 { z with value = 0 }
And one can write:

   match x with
   | A | B -> f1
   | C -> f2

There are no comments on this comment yet.