4 ms·
Scala, Kotlin, Haxe, Swift, and several others. The search term you want is "Algebraic Data Types" Erlang has the superpowered version of this - binary pattern
by pdpi 4y ago
Scala, Kotlin, Haxe, Swift, and several others. The search term you want is "Algebraic Data Types"
Erlang has the superpowered version of this - binary pattern matching, that lets you pattern match on a bitstream directly.
- rad_gruchalski 4y agoErlang also has exhaustive pattern matching. To the extent of having to declare catch all arity for functions.
- masklinn 4y ago> Erlang has the superpowered version of this - binary pattern matching, that lets you pattern match on a bitstream directly. Erlang has a super-powered version of the pattern matching bit, but not of what GP actually likes about it: > you have to handle every case whenever you're matching on it because Erlang is dynamically typed. So partial patterns are acceptable, and not entirely uncommon.
- andrewflnr 4y agoBinary pattern matching is very cool, but I wouldn't call it a version of ADT matching.
- vips7L 4y agoDon't forget Java :)
- valenterry 4y agoIt's not there yet, is it?
- vips7L 4y agoPattern matching and exhaustive switch expressions are in preview.
- valenterry 4y agoLet's hope it comes soon then! But right now, I think Java can't be counted in.
- vips7L 4y agoI’m using it
- hota_mazi 4y agoErlang doesn't have enums.
- andrewflnr 4y agoI almost said the same thing, but a tuple starting with an atom is basically the dynamically typed version of an enum. :) You can safely think of ADTs as sugar and typing rules for such tuples, though I believe you do need dependent types to come at it from that direction...