Last active
January 19, 2017 03:05
-
-
Save kevinmeredith/654a2c4da41e49c01426518e33885292 to your computer and use it in GitHub Desktop.
Attempt to implement `Init` per shapeless-guide book
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
| package net | |
| import shapeless.{::, DepFn1, HList} | |
| trait Init[L <: HList] extends DepFn1[L] | |
| object Init { | |
| type Aux[L <: HList, Out1] = Init[L] { type Out = Out1} | |
| def apply[L <: HList](implicit ev: Init[L]): Aux[L, ev.Out] = ev | |
| implicit def atLeast1[H, L <: HList]: Aux[H :: L, L] = | |
| new Init[H :: L] { | |
| type Out = L | |
| def apply(in: H :: L): Out = in.tail | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
testing