3 ms·
I think Scala's pattern matching is pretty cool too. I was surprised by how weak Haskell's pattern matching is by comparison (by default, I don't yet know of an
by bad_user 8y ago
I think Scala's pattern matching is pretty cool too. I was surprised by how weak Haskell's pattern matching is by comparison (by default, I don't yet know of any GHC extensions that could help).
That said F# and Scala aren't really competitors. The real competitors are the mainstream languages, like JavaScript, Java, C# and Python and that's what their marketing should target.
- dwohnitmok 8y agoIf you're talking about custom `unapply` and `unapplySeq` functions, the equivalent-ish GHC extension is `ViewPatterns`.
- Tarean 8y agoPattern synonyms are really expressive but the complex version is kinda headache inducing: http://hackage.haskell.org/package/lens-4.17/docs/src/Control.Lens.Cons.html#%3A< http://hackage.haskell.org/package/lens-4.17/docs/src/Contro... This creates a bidirectional pattern synonym - you can both match and construct values with it: foo :: Cons' s Char => s -> s foo (a :< b) = 'c' :< b foo other = other Pattern synonyms make completeness checking undecidable so you need to give manual hints to get a nice api. It also wreaks cost models - is foo O(1) or O(n)?