Scala 从轻量级模块化登台开始
我正试着开始试验, 但是他们的网页缺少一个很好的简单测试示例,从开始到结束显示所有内容,该示例将测试所有内容是否正确安装和设置。因此,我很难做到这一点。我试图模仿我在LMS核心的testsrc子目录中找到的内容 到目前为止,我已经做了以下工作: 从github克隆并安装 按要求安装了 从github安装了 然后我尝试创建一个新的SBT项目,包括: 配置文件build.sbt: 和一个简单的程序src/main/scala/hw.scala: 但我不能让它编译。我得到以下错误:Scala 从轻量级模块化登台开始,scala,Scala,我正试着开始试验, 但是他们的网页缺少一个很好的简单测试示例,从开始到结束显示所有内容,该示例将测试所有内容是否正确安装和设置。因此,我很难做到这一点。我试图模仿我在LMS核心的testsrc子目录中找到的内容 到目前为止,我已经做了以下工作: 从github克隆并安装 按要求安装了 从github安装了 然后我尝试创建一个新的SBT项目,包括: 配置文件build.sbt: 和一个简单的程序src/main/scala/hw.scala: 但我不能让它编译。我得到以下错误: [error] .
[error] ....../src/main/scala/hw.scala:22: not found: type Rep
[error] def compute(b: Boolean): Rep[Int] = {
[error] ^
[error] ....../src/main/scala/hw.scala:21: not found: type Rep
[error] def snippet(x: Rep[Int]) = {
[error] ^
[error] two errors found
[error] (compile:compile) Compilation failed
“Rep”是LMS的基本结构,我认为它应该从公共领域引入。但不知何故,它不起作用。我做错了什么?抽象类型成员Rep[T]在trait中声明。为了使用Rep[T]类型,您需要在包含基本特征的混合合成中编写程序
开始使用LMS的最简单方法是遵循PLDI 2013的要求
package scala.virtualization.lms
package epfl
import common._
object Hi {
def snippet(x: Rep[Int]) = {
def compute(b: Boolean): Rep[Int] = {
// the if is executed in the first stage
if (b) 1 else x
}
compute(true)+compute(1==1)
}
def main(args: Array[String]) =
println("Hello World!")
}
[error] ....../src/main/scala/hw.scala:22: not found: type Rep
[error] def compute(b: Boolean): Rep[Int] = {
[error] ^
[error] ....../src/main/scala/hw.scala:21: not found: type Rep
[error] def snippet(x: Rep[Int]) = {
[error] ^
[error] two errors found
[error] (compile:compile) Compilation failed