[ANN] funKTionale, functionals constructs and patters for Kotlin


#1

Hi Kotlin friends,

Check my new project https://github.com/MarioAriasC/funKTionale

This is my second Kotlin library, (the other one, KotlinPrimavera will be updated soon).

Currently funKTionale have function composition, partial application and function currying for Kotlin functions

Other features are planned.

Any suggestion, feature proposal and bug reports are welcomed.

Enjoy it

Cheers


#2

Looks very good!

One suggestion: what you call “partial application” is usually called “<a href=“http://en.wikipedia.org/wiki/Currying”>currying”, and what you call “currying” is usually nut present at all. This may lead to some confusion.
I’d consider to change the names.


#3

Actually, are two different things: Currying http://en.wikipedia.org/wiki/Currying and Partiall application http://en.wikipedia.org/wiki/Partial_application that sometimes are confusing http://en.wikipedia.org/wiki/Currying#Contrast_with_partial_function_application

And maybe my implementation is leading to more confusion, I’ll check it out

Thanks Andrey


#4

Your terminology is right. I take my note back. Sorry


#5

Some observations:

Sometimes the ‘andThen’ function is known as ‘forwardCompose’.
It might be worth including a synonym.

Having defined a function in its curried form there might be a requirement to pass a reference
to it but in its uncurried form. You might then consider ‘uncurry’ as well as ‘curry’.

With curried functions and compositions of them, the functions ‘identity’, ‘constant’ and 'flip’
can also prove useful:

fun <X> identity(x: X): X = x

fun <X, Y> constant(x: X): (Y) -> X = {(y: Y) -> x}

fun <X, Y, Z> flip(f: (X) -> (Y) -> Z): (Y) -> (X) -> Z = {y -> {x -> f(x)(y)}}

If others come to mind I will alert you.

Ken


#6

WOW,  Cool, I really love the "forwardCompose" name. :)

I’ll study the other suggestions and implemented it if possible (Some of then could be hard)

I see in other forum thread that you’re working on a Option Type, Could you share your code with me, please?   I’m going to start with an Either Type and other functional types

Thanks


#7

Mario

I have made my sources for the Option and Either types at:

Option [https://www.dropbox.com/s/las1oxmlj9blr73/Option.src.zip]
Either [https://www.dropbox.com/s/926bnnn2binoep1/Either.src.zip]

The binaries are included in the library previously mentioned.

Ken