Skip to content

Instantly share code, notes, and snippets.

@animeshsrivastava24
Forked from nicerobot/Story.scala
Created June 14, 2018 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save animeshsrivastava24/23493c58ac522a451f0142df21a0d211 to your computer and use it in GitHub Desktop.
Save animeshsrivastava24/23493c58ac522a451f0142df21a0d211 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!"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment