diff --git a/core/src/main/scala/fluence/hackethberlin/Expr.scala b/core/src/main/scala/fluence/hackethberlin/Expr.scala index 69e4c2f..6482b94 100644 --- a/core/src/main/scala/fluence/hackethberlin/Expr.scala +++ b/core/src/main/scala/fluence/hackethberlin/Expr.scala @@ -15,8 +15,8 @@ sealed trait InlineExpr[T] extends Expr[T] with Expr.ToInlineVyper { def :=:(name: Symbol): Free[Expr, Expr.Ref[T]] = Free.liftF[Expr, Expr.Ref[T]](Expr.Assign[T](Expr.Ref[T](name.name, boxedValue), this)) - def :==:(ref: Expr.Ref[T]): Free[Expr, Expr.Ref[T]] = - Free.liftF[Expr, Expr.Ref[T]](Expr.Assign[T](ref, this)) + def :=:[J <: T](ref: Expr.Ref[J]): Free[Expr, Expr.Ref[T]] = + Free.liftF[Expr, Expr.Ref[T]](Expr.Assign[T](Expr.Ref[T](ref.name, ref.boxedValue), this)) } object Expr { diff --git a/core/src/main/scala/fluence/hackethberlin/Untag.scala b/core/src/main/scala/fluence/hackethberlin/Untag.scala deleted file mode 100644 index bdc02e8..0000000 --- a/core/src/main/scala/fluence/hackethberlin/Untag.scala +++ /dev/null @@ -1,62 +0,0 @@ -package fluence.hackethberlin - -import scala.language.implicitConversions -import shapeless._ -import shapeless.Everywhere -import ops.hlist.{Align, Mapper, Prepend} -import poly._ -import record._ -import syntax.singleton._ -import shapeless.tag -import tag.{@@, Tagged} - -object untag extends Poly1 { - implicit def ut[A, B] = at[A @@ B]{ x => - println("untagging " + x) - x.asInstanceOf[A] - } - - trait Converter[G <: HList, A] { - def convert(g: G): A - } - - implicit def convert[A, F <: HList, G <: HList](implicit - gen: LabelledGeneric.Aux[A, F], - align: Align[G, F]) = - new Converter[G, A] { - def convert(g: G) = gen.from(align(g)) - } - - implicit class ToConverter[G <: HList, R <: HList, F <: HList](ag: (R, F)) { - def convertTo[B](implicit p: Prepend.Aux[R, F, G], c: Converter[G, B]) = - c.convert(ag._1 ++ ag._2) - } - - implicit class Untag[A, R <: HList](a: A)(implicit - gen: LabelledGeneric.Aux[A, R], - val e: Everywhere[untag.type, R]) { - def untagged: e.Result = e(gen.to(a)) - } -} - -object Example extends App { - - import untag._ - - trait TagInt {} - - case class Foo(a: String, b: Int @@ TagInt) - case class Bar(b: Int, a: String, c: String, d: Int) - case class Baz(a: String, b: Int) - - - - println(Foo("foo", tag[TagInt](1)).untagged) - // Next line is broken, type info is lost coming from call to untagged - // poly is being applied to the tagged field as output shows - - // println(Foo("foo", tag[TagInt](1)).untagged, (('d ->> 3) :: ('c ->> "bar") :: HNil)).convertTo[Bar]) - - val gbz = LabelledGeneric[Baz] - println((gbz.to(Baz("foo", 1)), (('d ->> 3) :: ('c ->> "bar") :: HNil)).convertTo[Bar]) -} diff --git a/core/src/main/scala/fluence/hackethberlin/types/ProductType.scala b/core/src/main/scala/fluence/hackethberlin/types/ProductType.scala index 270244a..c7a60d8 100644 --- a/core/src/main/scala/fluence/hackethberlin/types/ProductType.scala +++ b/core/src/main/scala/fluence/hackethberlin/types/ProductType.scala @@ -7,8 +7,6 @@ import shapeless.ops.record.Selector class ProductType[D <: HList](dataDef: D, dv: DataVyper[D]) extends Type { - import fluence.hackethberlin.untag._ - def ref[T <: Symbol, V <: Type](k: Witness.Aux[T])(implicit selector: Selector.Aux[D, T, V]): Expr.Ref[V] = Expr.Ref[V](k.value.name, selector(dataDef)) diff --git a/src/main/scala/fluence/MakeVyperApp.scala b/src/main/scala/fluence/MakeVyperApp.scala index 111fba0..0111e95 100644 --- a/src/main/scala/fluence/MakeVyperApp.scala +++ b/src/main/scala/fluence/MakeVyperApp.scala @@ -52,7 +52,7 @@ object MakeVyperApp extends App { for { c ← 'c :=: `++`(args.ref('a), args.ref('b)) d ← 'd :=: `++`(args.ref('b), c) - _ ← d :==: c + _ ← d :=: c sum ← `++`(args.ref('a), d).toReturn } yield sum } @@ -71,6 +71,7 @@ object MakeVyperApp extends App { } object Auction { + val data = ProductType( ('beneficiary ->> public(address)) :: ('auction_start ->> public(timestamp)) :: @@ -99,22 +100,21 @@ object Auction { Void ) { args ⇒ for { - _ <- Free.pure(Void) -// _ <- beneficiary :==: _beneficiary + _ <- Free.pure(Void) + _ <- beneficiary :=: _beneficiary // _ <- auction_start :==: block.timestamp // _ <- auction_end :==: auction_start `+:+` _bidding_time } yield Void } - - val bid = `@public` @: `@payable` @: ProductType(HNil).funcDef( + /*val bid = `@public` @: `@payable` @: ProductType(HNil).funcDef( "bid", Void ) { args ⇒ for { _ <- Free.pure(Void) - _ <- `assertt` (block.timestamp `<` auction_end) - _ <- `assertt` (msg.value `>` highest_bid) + _ <- `assertt`(block.timestamp `<` auction_end) + _ <- `assertt`(msg.value `>` highest_bid) } yield Void - } -} \ No newline at end of file + }*/ +}