2 ms·
"...whose type indicates its state" This is one of my favorite scenarios facilitated by static types. And one of the reasons I like languages with ML-like synt
by fsloth 12y ago
"...whose type indicates its state"
This is one of my favorite scenarios facilitated by static types. And one of the reasons I like languages with ML-like syntax for algebraic datatypes and pattern matching - this pattern is so easy to implement in them
http://en.wikipedia.org/wiki/Algebraic_data_type http://en.wikipedia.org/wiki/Algebraic_data_type
An concise example of the usage can be found in
http://queue.acm.org/detail.cfm?id=2038036 http://queue.acm.org/detail.cfm?id=2038036
(Section starting with the sentence "Consider as an example the following types for representing the state of a network
connection:")
That's in Ocaml but the same syntax applies more or less to all languages with ADT:s.