Skip to Content
Mastering Functional Programming
book

Mastering Functional Programming

by Anatolii Kmetiuk
August 2018
Intermediate to advanced
380 pages
10h 2m
English
Packt Publishing
Content preview from Mastering Functional Programming

Type classes in different languages

In principle, the idea of type classes is present even in Java. For example, Java has the Comparator interface, which defines how to compare two arbitrary types. It defines a relationship of order on a type. The type that is used with collections defines the order in which they are sorted.

However, a language such as Java lacks a mechanism for applying that class to types conveniently. So, for example, when you are sorting a collection, you need to explicitly provide an instance of the type class to the sorting method. This is unlike Scala, where it is possible to use implicit conversions and implicit lookup for the compiler to look up the implementation of the type class by itself, so as not to clutter ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Functional Programming

Learning Functional Programming

Jack Widman

Publisher Resources

ISBN: 9781788620796Supplemental Content