Created
December 2, 2012 06:42
-
-
Save tldeti/4187382 to your computer and use it in GitHub Desktop.
example
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
package org.tldeti | |
import shapeless._ | |
import Nat._ | |
trait Business[T<:Nat] | |
object Business { | |
def fromData[T<:Nat](n:Int,t:T)(implicit witness:Int=>Business[T]): Business[T] = n | |
implicit final def business1Witness(n: Int): Business1 = new Business1(n) | |
// implicit final def business2Witness(n: Int): Business2 = new Business2(n) | |
class Business1(n:Int) extends Business[_1] | |
class Business2(n:Int) extends Business[_2] | |
} | |
object Test extends App{ | |
Business.fromData(3,_1) | |
// Business.fromData(3,_2) | |
// Business.fromData(3,_3) not compile | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment