News for hackers. Stuff that matters.
Re:State of the Art JavaScript in 2016 by spicyj on Friday March 11, 2016 @06:38PM (#11270400)
Flow has pretty good support for tagged unions like this which act like ADTs:

http://flowtype.org/blog/2015/07/03/Disjoint-Unions.html

Re:State of the Art JavaScript in 2016 by fleshweasel on Friday March 11, 2016 @06:47PM (#11270446)
This is great. Seems less cumbersome than TypeScript's user defined type guards for distinguishing cases of a union. The sentinel value concept is something you could at least steal when creating user defined type guards to make them simpler, at least.
Re:State of the Art JavaScript in 2016 by wereHamster on Saturday March 12, 2016 @02:04PM (#11274010)
TypeScript union types and Flow tagged unions are nice to have, but to make them really useful you also have to provide a good way to pattern match on them. And there they both are still way behind Haskell.
Re:State of the Art JavaScript in 2016 by lomnakkus on Friday March 11, 2016 @06:45PM (#11270439)
That's interesting! I haven't paid much attention to Flow since trying out the initial release and finding it a bit lacking. (But then, I'm used to GHC/Haskell, so everything lacking!)

I truly feel that "disjoint unions" is one of those things you don't appreciate the true value of until you've used them for quite a while. The real eye-opener for me was implementing a state machine and finding that I could explicitly state exactly which bits of the state machine would propagate to $NEXT_STATE at every step... and have the compiler double-check for me that I got it right.

EDIT: I accidentally a accidentally.

Re:State of the Art JavaScript in 2016 by spicyj on Friday March 11, 2016 @06:51PM (#11270463)
It's gotten a lot better since the initial release. Obviously no match for GHC but it's not trying to be, either. :)
Re:State of the Art JavaScript in 2016 by lomnakkus on Friday March 11, 2016 @07:01PM (#11270511)
Understood :).
Re:State of the Art JavaScript in 2016 by fpoling on Saturday March 12, 2016 @08:45AM (#11272823)
This is really nice with a very good much to common JS patterns. Among other things it types the usage of string literals making possible to typecheck and refactor code that contains if (foo === 'bar').