Created
April 3, 2013 02:46
-
-
Save tixxit/5298038 to your computer and use it in GitHub Desktop.
This file contains 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
import shapeless._ | |
final class AnyRefCounter[L <: HList, N <: Nat] | |
object AnyRefCounter { | |
implicit def empty = new AnyRefCounter[HNil, Nat._0] | |
implicit def anyRef[H <: AnyRef, T <: HList, N <: Nat](implicit c: AnyRefCounter[T, N]) = new AnyRefCounter[H :: T, Succ[N]] | |
implicit def anyVal[H <: AnyVal, T <: HList, N <: Nat](implicit c: AnyRefCounter[T, N]) = new AnyRefCounter[H :: T, N] | |
def countRefs[L <: HList, N <: Nat](xs: L)(implicit c: AnyRefCounter[L, N], n: ToInt[N]): Int = n() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment