Last active
September 11, 2017 02:49
-
-
Save logicalguess/a9575ea10fda571ff21e4e5dd74aa869 to your computer and use it in GitHub Desktop.
mapper from an HList to another
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait HListMapper[In <: HList, Out <: HList] { | |
| def apply(in: In): Out | |
| } | |
| object HListMapper { | |
| implicit def caseHNil: HListMapper[HNil, HNil] = (in: HNil) => HNil | |
| implicit def caseHList[H1, H2, T1 <: HList, T2 <: HList] | |
| ( | |
| implicit | |
| headMapper: H1 => H2, | |
| tailMapper: HListMapper[T1, T2] | |
| ): HListMapper[H1 :: T1, H2 :: T2] = (in: H1 :: T1) => headMapper(in.head) :: tailMapper(in.tail) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment