clone https://github.com/milessabin/shapeless.git
cd shapeless
sbt
-- in sbt:
++2.11.11
coreNative/publishM2
exit
clone https://github.com/Rudogma/scala-superquants.git
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 scala.language.higherKinds | |
object tag3 { | |
private def cast[T, U](v:U):T = v.asInstanceOf[T] | |
type Tag[T, +U] = { type Raw = T ; type Gag <: U } | |
type @@[T, +U] = T with Tag[T, U] | |
type Tagged[T, +U] = T with Tag[T, U] |
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 scala.language.higherKinds | |
package object tag { | |
private def cast[T, U](v: U): T = v.asInstanceOf[T] | |
type Tag[T, +U] = {type Raw = T ; type Gag <: U } | |
type @@[T, +U] = T with Tag[T, U] | |
type Tagged[T, +U] = T with Tag[T, U] | |
def tag[T, U](value:T):T @@ U = cast(value) |
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 scala.language.dynamics | |
object Test extends App { | |
implicit class MyVal[T](val value:T) extends AnyVal | |
class Test1 extends Dynamic { | |
def selectDynamic(field:String):String = "Hello" | |
} |
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.ops.nat.ToInt | |
import shapeless.{Nat, Succ} | |
import scala.concurrent.Promise | |
import scala.util.{Failure, Success} | |
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits._ | |
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 supertagged._ | |
/*** ONE TIME PREDEF **/ | |
trait Opp { | |
type Operation | |
type Divide <: Operation | |
type Multiply <: Operation | |
} |
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 org.scalatest.{FlatSpec, Matchers} | |
import shapeless.test.illTyped | |
import TestOverTagged2._ | |
import supertagged.{OverTagged, Tag, Tagged, TaggedType, TaggedTypeF} | |
import scala.language.higherKinds | |
class TestOverTagged2 extends FlatSpec with Matchers { |
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 scala.language.implicitConversions | |
object Test extends App { | |
testShapeless() | |
TestSupertagged.testSupertagged() | |
def testShapeless(){ | |
import shapeless.newtype |
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.scala -- | |
object Booter extends TaggedType[Int] | |
type Booter = Booter.Type | |
implicit class StepOps(val __v:Int) { | |
def next:Step = Step @@ (__v + 1) | |
def +(v2:Int):Step = Step @@ (__v + v2) | |
} | |
object Step extends NewType[Int, StepOps] |
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 scala.language.higherKinds | |
import scala.language.implicitConversions | |
object TestNewtypes extends App { | |
/** | |
Changed lines: | |
type NewType = Newtype[T, Tag0] with superduper.Tag[T, this.type] | |
def apply[TagIn, Sub, C](c: C)(implicit tagger: Tagger[TagIn, Type, Tag, Sub, C]): NewType = c.asInstanceOf[T with NewType] |
OlderNewer