Skip to content

Instantly share code, notes, and snippets.

@tldeti
Created December 2, 2012 06:42
Show Gist options
  • Save tldeti/4187382 to your computer and use it in GitHub Desktop.
Save tldeti/4187382 to your computer and use it in GitHub Desktop.
example
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