a -> a -> a addNums a b c = a + b + c addNums 1 2 3 -- 6 addNumsTo2 :: Num a => a -> a -> a addNumsTo2 = addNums 2 addNumsTo2 3 4 -- 9 How do I do this in Kotlin?
of arguments (arity). • Difference: • Partial application decreases number of arguments by 1. • Currying decomposes multi argument functions into multiple 1 argument functions.
can be mapped over. The type has a mapping function defined on it. The mapping is homomorphic. class Functor map : ( (a -> b) -> f a ) -> f b Function from a to b Functor on a Functor on b
: Option<Nothing>() data class Some<out A>(val value: A) : Option<A>() inline fun <B> map(f: (A) -> B): Option<B> = when (this) { is Option.None -> this is Option.Some -> Option.Some(f(value)) } }