Created
September 9, 2017 18:11
-
-
Save knightpop/7b302288b5ec2a93ef6f8a9e2b550ede 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.{Coproduct, CNil, :+:, Inl, Inr} | |
type Id = UserId :+: DeviceUuid :+: CarSerialId :+: CNil | |
def getId(id: Id): Long = id match { | |
case Inl(userId) => userId + 1 | |
case Inr(Inl(deviceUuid)) => deviceUuid + 2 | |
case Inr(Inr(Inl(carSerialId))) => carSerialId + 3 | |
case Inr(Inr(Inr(cNil))) => 0 | |
} | |
getId(Coproduct[Id](taggedUserId)) | |
getId(Coproduct[Id](taggedDeviceUuid)) | |
getId(Coproduct[Id](taggedCarSerialId)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment