-
-
Save animeshsrivastava24/23493c58ac522a451f0142df21a0d211 to your computer and use it in GitHub Desktop.
Simple Scala "DSL" example using easy to understand constructs.
This file contains 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 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