Hacker News new | ask | show | jobs
by nirvdrum 2485 days ago
Okay, thanks for elaborating. I think the part I had overlooked was the variant constructor not being a function. I had mentally mapped that as a `dispatch` call with the variant being the payload. But, yeah, it looks like the author either made a mistake or took a shortcut there.
1 comments

BuckleScript (ReasonML's-to-JavaScript compiler) has an annotation that automatically creates functions from variant constructors. E.g.:

    [@bs.deriving {accessors}]
    type msg =
    | Increment
    | Decrement
    | Reset
    | Set(int);

    let action = set(2);