mirror of
https://github.com/fluencelabs/hackethberlin
synced 2025-04-25 09:22:21 +00:00
Main code moved to core subproject
This commit is contained in:
parent
9c2f0fe72c
commit
f4d186dfa9
35
build.sbt
35
build.sbt
@ -4,26 +4,37 @@ version := "0.1"
|
|||||||
|
|
||||||
scalaVersion := "2.12.6"
|
scalaVersion := "2.12.6"
|
||||||
|
|
||||||
resolvers += Resolver.sonatypeRepo("releases")
|
|
||||||
|
|
||||||
addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.7")
|
addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.7")
|
||||||
|
|
||||||
version := "0.1"
|
val commons = Seq(
|
||||||
fork in Test := true
|
version := "0.1",
|
||||||
parallelExecution in Test := false
|
fork in Test := true,
|
||||||
organizationName := "Fluence Labs Limited"
|
parallelExecution in Test := false,
|
||||||
organizationHomepage := Some(new URL("https://fluence.one"))
|
organizationName := "Fluence Labs Limited",
|
||||||
startYear := Some(2018)
|
organizationHomepage := Some(new URL("https://fluence.one")),
|
||||||
licenses += ("Apache-2.0", new URL("https://www.apache.org/licenses/LICENSE-2.0.txt"))
|
startYear := Some(2018),
|
||||||
//headerLicense := Some(License.ALv2("2018", organizationName.value))
|
licenses += ("Apache-2.0", new URL("https://www.apache.org/licenses/LICENSE-2.0.txt")),
|
||||||
resolvers += Resolver.bintrayRepo("fluencelabs", "releases")
|
//headerLicense := Some(License.ALv2("2018", organizationName.value)),
|
||||||
scalafmtOnCompile := true
|
resolvers += Resolver.bintrayRepo("fluencelabs", "releases"),
|
||||||
|
resolvers += Resolver.sonatypeRepo("releases"),
|
||||||
|
scalafmtOnCompile := true,
|
||||||
// see good explanation https://gist.github.com/djspiewak/7a81a395c461fd3a09a6941d4cd040f2
|
// see good explanation https://gist.github.com/djspiewak/7a81a395c461fd3a09a6941d4cd040f2
|
||||||
scalacOptions += "-Ypartial-unification"
|
scalacOptions += "-Ypartial-unification"
|
||||||
|
)
|
||||||
|
|
||||||
|
commons
|
||||||
|
|
||||||
|
lazy val core = project.settings(
|
||||||
|
commons,
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"org.typelevel" %% "cats-core" % "1.2.0",
|
"org.typelevel" %% "cats-core" % "1.2.0",
|
||||||
"org.typelevel" %% "cats-free" % "1.2.0",
|
"org.typelevel" %% "cats-free" % "1.2.0",
|
||||||
"com.chuusai" %% "shapeless" % "2.3.3",
|
"com.chuusai" %% "shapeless" % "2.3.3",
|
||||||
"org.scalatest" %% "scalatest" % "3.0.5" % Test
|
"org.scalatest" %% "scalatest" % "3.0.5" % Test
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
lazy val root = project
|
||||||
|
.in(file("."))
|
||||||
|
.dependsOn(core)
|
||||||
|
.aggregate(core)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fluence.hackethberlin
|
package fluence.hackethberlin
|
||||||
|
|
||||||
import cats.data.Writer
|
import cats.data.Writer
|
||||||
import cats.{~>, Monad, Monoid}
|
import cats.{~>, Monoid}
|
||||||
|
|
||||||
import scala.collection.immutable.Queue
|
import scala.collection.immutable.Queue
|
||||||
|
|
@ -1,15 +1,13 @@
|
|||||||
package fluence.hackethberlin
|
package fluence.hackethberlin
|
||||||
|
|
||||||
import cats.Monad
|
|
||||||
import fluence.hackethberlin.types.{DataVyper, ProductType}
|
import fluence.hackethberlin.types.{DataVyper, ProductType}
|
||||||
import shapeless._
|
import shapeless._
|
||||||
import cats.free.Free
|
import cats.free.Free
|
||||||
import cats.syntax.functor._
|
|
||||||
|
|
||||||
class FuncDef[Args <: HList, Ret <: types.Type](
|
class FuncDef[Args <: HList, Ret <: types.Type](
|
||||||
name: String,
|
name: String,
|
||||||
argsDef: ProductType[Args],
|
argsDef: ProductType[Args],
|
||||||
ret: Option[Ret],
|
ret: Ret,
|
||||||
body: ProductType[Args] ⇒ Free[Expr, Ret],
|
body: ProductType[Args] ⇒ Free[Expr, Ret],
|
||||||
decorators: Set[Decorator] = Set.empty
|
decorators: Set[Decorator] = Set.empty
|
||||||
) {
|
) {
|
||||||
@ -18,10 +16,14 @@ class FuncDef[Args <: HList, Ret <: types.Type](
|
|||||||
body(argsDef).foldMap(CodeChunk.fromExpr).run._1.toVyper(1)
|
body(argsDef).foldMap(CodeChunk.fromExpr).run._1.toVyper(1)
|
||||||
|
|
||||||
def toVyper: String =
|
def toVyper: String =
|
||||||
s"${decorators.map(_.toVyper).mkString("\n")}\ndef $name(${argsDef.toArgsVyper})${ret.fold("")(" -> " + _.toVyper)}:\n$bodyVyper\n"
|
s"${decorators.map(_.toVyper).mkString("\n")}\ndef $name(${argsDef.toArgsVyper})${Option(ret)
|
||||||
|
.filter(_ != types.Void)
|
||||||
|
.fold("")(" -> " + _.toVyper)}:\n$bodyVyper\n"
|
||||||
|
|
||||||
def @:(decorator: Decorator): FuncDef[Args, Ret] =
|
def @:(decorator: Decorator): FuncDef[Args, Ret] =
|
||||||
new FuncDef[Args, Ret](name, argsDef, ret, body, decorators + decorator)
|
new FuncDef[Args, Ret](name, argsDef, ret, body, decorators + decorator)
|
||||||
|
|
||||||
|
//def apply[Params <: HList](params: Params)(implicit a: LUBConstraint s: ops.hlist.Mapped[Args, InlineExpr]): InlineExpr[Ret] = ???
|
||||||
}
|
}
|
||||||
|
|
||||||
object FuncDef {
|
object FuncDef {
|
||||||
@ -31,12 +33,12 @@ object FuncDef {
|
|||||||
argsDef: Args,
|
argsDef: Args,
|
||||||
ret: Ret
|
ret: Ret
|
||||||
)(body: ProductType[Args] ⇒ Free[Expr, Ret]): FuncDef[Args, Ret] =
|
)(body: ProductType[Args] ⇒ Free[Expr, Ret]): FuncDef[Args, Ret] =
|
||||||
new FuncDef(name, ProductType(argsDef), Some(ret), body)
|
new FuncDef(name, ProductType(argsDef), ret, body)
|
||||||
|
|
||||||
def apply[Args <: HList: DataVyper](
|
def apply[Args <: HList: DataVyper](
|
||||||
name: String,
|
name: String,
|
||||||
argsDef: Args
|
argsDef: Args
|
||||||
)(body: ProductType[Args] ⇒ Free[Expr, Unit]): FuncDef[Args, types.Void] =
|
)(body: ProductType[Args] ⇒ Free[Expr, Unit]): FuncDef[Args, types.Void] =
|
||||||
new FuncDef(name, ProductType(argsDef), None, args ⇒ body(args).map(_ ⇒ types.Void))
|
new FuncDef(name, ProductType(argsDef), types.Void, args ⇒ body(args).map(_ ⇒ types.Void))
|
||||||
|
|
||||||
}
|
}
|
@ -23,7 +23,7 @@ class ProductType[D <: HList](dataDef: D, dv: DataVyper[D]) extends Type {
|
|||||||
dv.toVyperDefinitions(dataDef).mkString(", ")
|
dv.toVyperDefinitions(dataDef).mkString(", ")
|
||||||
|
|
||||||
def funcDef[Ret <: Type](name: String, ret: Ret)(body: ProductType[D] ⇒ Free[Expr, Ret]): FuncDef[D, Ret] =
|
def funcDef[Ret <: Type](name: String, ret: Ret)(body: ProductType[D] ⇒ Free[Expr, Ret]): FuncDef[D, Ret] =
|
||||||
new FuncDef[D, Ret](name, this, Some(ret), body)
|
new FuncDef[D, Ret](name, this, ret, body)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
package fluence.hackethberlin
|
package fluence
|
||||||
|
|
||||||
|
import hackethberlin._
|
||||||
|
import hackethberlin.types._
|
||||||
import shapeless._
|
import shapeless._
|
||||||
import types._
|
|
||||||
import Decorator._
|
import Decorator._
|
||||||
import cats.free.Free
|
|
||||||
import syntax.singleton._
|
import syntax.singleton._
|
||||||
|
|
||||||
object MakeVyperApp extends App {
|
object MakeVyperApp extends App {
|
Loading…
x
Reference in New Issue
Block a user