Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Functional Kotlin

You're reading from   Functional Kotlin Extend your OOP skills and implement Functional techniques in Kotlin and Arrow

Arrow left icon
Product type Paperback
Published in Feb 2018
Publisher Packt
ISBN-13 9781788476485
Length 350 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Table of Contents (22) Chapters Close

Title Page
Copyright and Credits
Dedication
Packt Upsell
Contributors
Preface
1. Kotlin – Data Types, Objects, and Classes FREE CHAPTER 2. Getting Started with Functional Programming 3. Immutability - It's Important 4. Functions, Function Types, and Side Effects 5. More on Functions 6. Delegates in Kotlin 7. Asynchronous Programming with Coroutines 8. Collections and Data Operations in Kotlin 9. Functional Programming and Reactive Programming 10. Functors, Applicatives, and Monads 11. Working with Streams in Kotlin 12. Getting Started with Arrow 13. Arrow Types 14. Kotlin's Quick Start 1. Other Books You May Enjoy Index

Partial application


With function composition, we take two functions to create the third function; with partial application, we create a new function by passing a parameter to an existing function.

Arrow comes with two flavours of partial application—explicit and implicit.

The explicit style uses a series of extension functions called partially1, partially2, all the way up to partially22. The implicit style takes a series of extensions, overloading the invoke operator:

package com.packtpub.functionalkotlin.chapter11

import arrow.syntax.function.invoke
import arrow.syntax.function.partially3

fun main(args: Array<String>) {
   val strong: (String, String, String) -> String = { body, id, style -> "<strong id=\"$id\" style=\"$style\">$body</strong>" }

   val redStrong: (String, String) -> String = strong.partially3("font: red") //Explicit

   val blueStrong: (String, String) -> String = strong(p3 = "font: blue") //Implicit

   println(redStrong("Red Sonja", "movie1...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images