Main code moved to core subproject

This commit is contained in:
alari 2018-09-08 17:34:35 +02:00
parent 9c2f0fe72c
commit f4d186dfa9
13 changed files with 43 additions and 30 deletions

View File

@ -4,26 +4,37 @@ version := "0.1"
scalaVersion := "2.12.6"
resolvers += Resolver.sonatypeRepo("releases")
addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.7")
version := "0.1"
fork in Test := true
parallelExecution in Test := false
organizationName := "Fluence Labs Limited"
organizationHomepage := Some(new URL("https://fluence.one"))
startYear := Some(2018)
licenses += ("Apache-2.0", new URL("https://www.apache.org/licenses/LICENSE-2.0.txt"))
//headerLicense := Some(License.ALv2("2018", organizationName.value))
resolvers += Resolver.bintrayRepo("fluencelabs", "releases")
scalafmtOnCompile := true
val commons = Seq(
version := "0.1",
fork in Test := true,
parallelExecution in Test := false,
organizationName := "Fluence Labs Limited",
organizationHomepage := Some(new URL("https://fluence.one")),
startYear := Some(2018),
licenses += ("Apache-2.0", new URL("https://www.apache.org/licenses/LICENSE-2.0.txt")),
//headerLicense := Some(License.ALv2("2018", organizationName.value)),
resolvers += Resolver.bintrayRepo("fluencelabs", "releases"),
resolvers += Resolver.sonatypeRepo("releases"),
scalafmtOnCompile := true,
// see good explanation https://gist.github.com/djspiewak/7a81a395c461fd3a09a6941d4cd040f2
scalacOptions += "-Ypartial-unification"
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % "1.2.0",
"org.typelevel" %% "cats-free" % "1.2.0",
"com.chuusai" %% "shapeless" % "2.3.3",
"org.scalatest" %% "scalatest" % "3.0.5" % Test
scalacOptions += "-Ypartial-unification"
)
commons
lazy val core = project.settings(
commons,
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % "1.2.0",
"org.typelevel" %% "cats-free" % "1.2.0",
"com.chuusai" %% "shapeless" % "2.3.3",
"org.scalatest" %% "scalatest" % "3.0.5" % Test
)
)
lazy val root = project
.in(file("."))
.dependsOn(core)
.aggregate(core)

View File

@ -1,7 +1,7 @@
package fluence.hackethberlin
import cats.data.Writer
import cats.{~>, Monad, Monoid}
import cats.{~>, Monoid}
import scala.collection.immutable.Queue

View File

@ -1,15 +1,13 @@
package fluence.hackethberlin
import cats.Monad
import fluence.hackethberlin.types.{DataVyper, ProductType}
import shapeless._
import cats.free.Free
import cats.syntax.functor._
class FuncDef[Args <: HList, Ret <: types.Type](
name: String,
argsDef: ProductType[Args],
ret: Option[Ret],
ret: Ret,
body: ProductType[Args] Free[Expr, Ret],
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)
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] =
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 {
@ -31,12 +33,12 @@ object FuncDef {
argsDef: Args,
ret: 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](
name: String,
argsDef: Args
)(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))
}

View File

@ -23,7 +23,7 @@ class ProductType[D <: HList](dataDef: D, dv: DataVyper[D]) extends Type {
dv.toVyperDefinitions(dataDef).mkString(", ")
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)
}

View File

@ -1,9 +1,9 @@
package fluence.hackethberlin
package fluence
import hackethberlin._
import hackethberlin.types._
import shapeless._
import types._
import Decorator._
import cats.free.Free
import syntax.singleton._
object MakeVyperApp extends App {