3 ms·
Maybe you haven't checked out Kotlin lately? Kotlin has somewhat pattern matching: https://kotlinlang.org/docs/reference/control-flow.html#when-expression http
by pillowkusis 9y ago
Maybe you haven't checked out Kotlin lately?
Kotlin has somewhat pattern matching: https://kotlinlang.org/docs/reference/control-flow.html#when-expression https://kotlinlang.org/docs/reference/control-flow.html#when...
Tail call optimization: https://kotlinlang.org/docs/reference/functions.html#tail-recursive-functions https://kotlinlang.org/docs/reference/functions.html#tail-re...
Type classes: https://kotlinlang.org/docs/reference/sealed-classes.html https://kotlinlang.org/docs/reference/sealed-classes.html
And I'm not sure what you mean by recursive data structures. Basically every C style language I'm aware of can contain a reference to another instance of its own type.
It's more java-y than Scala, but it's fundementally capable of a very FP style.
- Filligree 9y ago> Type classes: https://kotlinlang.org/docs/reference/sealed-classes.html https://kotlinlang.org/docs/reference/sealed-classes.html Those are not type-classes, at least not in the Haskell sense. They allow you to avoid an else branch, yes, which is actually quite useful; but one basic ability they're missing is the ability to define a new branch for a new instance of the type defined by library users. Just as an example. They're really not much like type-classes at all.
- jnbiche 9y agoI agree with Filligree that sealed classes are not really capable of emulating type classes. They can be used for algebraic data types, which is great, but for true extensible type classes you'd need something like Scala traits.
- masklinn 9y ago> Type classes: https://kotlinlang.org/docs/reference/sealed-classes.html https://kotlinlang.org/docs/reference/sealed-classes.html Sealed classes are an odd/wonky take on sum types, they're not even remotely close to type classes.
- zejay 9y agoTail recursion is a special case of tail calls that can be turned into loops. Their keyword is called tailrec, so it's probably not real TCO. Real tail call optimization can't easily be turned into loops in the general case.