Skip to content

Instantly share code, notes, and snippets.

@nicerobot
Created December 2, 2012 16:19
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save nicerobot/4189552 to your computer and use it in GitHub Desktop.
Save nicerobot/4189552 to your computer and use it in GitHub Desktop.
Simple Scala "DSL" example using easy to understand constructs.
name := "story"
version := "1.0"
scalaVersion := "2.9.2"
mainClass in (Compile, run) := Some("Story")
object Story {
object Once { def upon = (x: a.type) => x }
object a { def time = (x: languages.type) => x }
object languages { def were = (x: inflexible.type) => x }
object inflexible { def along = (x: came.type) => x }
object came { def Scala = (x: inflexible.type) => x }
implicit def string(s : String) : inflexible.type = inflexible
def main(args: Array[String]): Unit = {
Once upon a time languages were inflexible; "Then " along came Scala ". The End!"
}
}
@cpscofield
Copy link

This example appears to out-of-date with Scala version 2.13.10.

  1. build.sbt/7: 'in' is deprecated.
  2. build.sbt/7 ':=' is not recognized.

I get other errors, too many to comment on here. I get an enormous stack-trace that begins with:

error: error while loading package, Missing dependency 'class java.lang.Object', required by C:\Users\carys\AppData\Local\Coursier\Cache\v1\https\repo1.maven.org\maven2\org\scala-lang\scala-library\2.9.2\scala-library-2.9.2.jar(scala/package.class)
error: scala.tools.nsc.MissingRequirementError: class java.lang.String not found.

How to resolve this? Other Scala projects I have that don't use DSL work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment