Created
December 2, 2012 16:19
-
-
Save nicerobot/4189552 to your computer and use it in GitHub Desktop.
Simple Scala "DSL" example using easy to understand constructs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name := "story" | |
version := "1.0" | |
scalaVersion := "2.9.2" | |
mainClass in (Compile, run) := Some("Story") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This example appears to out-of-date with Scala version 2.13.10.
I get other errors, too many to comment on here. I get an enormous stack-trace that begins with:
How to resolve this? Other Scala projects I have that don't use DSL work fine.