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

Reclusive implicit resolution

Let's get a big picture understanding of what the members of the MapToDouble companion object look like:

object MapToDouble {  type Aux[L <: HList, LR <: HList] = MapToDouble[L] { type Result = LR }  def apply[L <: HList](implicit m: MapToDouble[L]) = m  implicit def hcons[H, T <: HList, TR <: HList](implicit    td: ToDouble[H]  , md: MapToDouble.Aux[T, TR]  ): Aux[H ::: T, Double ::: TR]  implicit def hnil[H <: HNil]: MapToDouble.Aux[H, HNil]}

So as you can see, we have an Aux type, and apply function definitions, which are common for the type class pattern. Also, we have two implicit members, which define implementations for the MapToDouble type class for hlist. Since there are two possible instances of hlist, we have ...

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