Skip to content

Instantly share code, notes, and snippets.

@ekmett
Created December 5, 2010 14:07
Embed
What would you like to do?
scala> import magpie._
import magpie._
scala> type i = hom.set.singleton[Int]
defined type alias i
scala> type arr = hom.set.of[Nothing,Any,({type o[-x,+y] = y})#o, ({type f[-x,+y] = x => y })#f]
defined type alias arr
scala> (_/2) : arr#hom[Int,Double]
res0: (Int) => Double = <function1>
scala> res0(12)
res1: Double = 6.0
scala> 12 : i#hom[Int,Int]
res3: Int = 12
scala> (12,24) : i2#hom[typed.product[Int,Int],typed.product[Int,Int]]
res6: magpie.typed.product[Int,Int] = (12,24)
scala> typed.product[Int,Int](12,24) : i2#hom[typed.product[Int,Int],typed.product[Int,Int]]
res7: magpie.typed.product[Int,Int] = (12,24)
scala> type iarr = hom.set.product[i,arr]
defined type alias iarr
scala> typed.product[Int,Int => Double](12, _/2) : iarr#hom[typed.product[Int,Int], typed.product[Int,Double]]
<console>:12: error: type mismatch;
found : magpie.typed.product[Int,(Int) => Double]
required: magpie.typed.product[Int,(Any forSome { val _25: magpie.hom.set{type obinf = Nothing; type obsup = Any; type ob[-a,+b(in type ob)] = b(in type ob); type inf = Nothing; type sup = Any; type hom[-a(in type hom),+b(in type hom)] = (a(in type hom)) => b(in type hom)} }) => Any forSome { val _25: magpie.hom.set{type obinf = Nothing; type obsup = Any; type ob[-a,+b(in type ob)] = b(in type ob); type inf = Nothing; type sup = Any; type hom[-a(in type hom),+b(in type hom)] = (a(in type hom)) => b(in type hom)} }]
typed.product[Int,Int => Double](12, _/2) : iarr#hom[typed.product[Int,Int], typed.product[Int,Double]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment