Just recently (in an answer in <#C0B8MA7FA|getting...
# stdlib
r
Just recently (in an answer in #getting-started) I found myself writing these functions:
Copy code
fun <A, B,    R> ((A, B   ) -> R).curry(a: A): (B   ) -> R = { b: B       -> this(a, b   ) }
fun <A, B, C, R> ((A, B, C) -> R).curry(a: A): (B, C) -> R = { b: B, c: C -> this(a, b, c) }
Do they already exist in the stdlib? Or are they a bit too Haskelly for Kotlin?
k
I can't find anything similar in the stdlib; maybe they exist under some name. I don't think they're too Haskelly; the C++ Standard Library has such a function (named
bind
instead of
curry
) - see e.g. https://stackoverflow.com/a/6610165/13963086
👍 1
m
r
Yes, I'm sure there must be loads of functional libs providing this, it's such an obvious and easy thing to write - and consequently felt like something I might expect to see in the stdlib.
e
Kotlin's type inference doesn't work on lambdas in receiver position so even if it were a common pattern I don't think you'll see functions like this in stdlib
👍 1