diff options
author | michelou <michelou@epfl.ch> | 2007-05-16 13:30:30 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2007-05-16 13:30:30 +0000 |
commit | 1f65685c9626929f3e6d7b81225f57fd4e68438c (patch) | |
tree | 54d3462ca86d36545ab6ef946a1095a0f15ac38f /docs/examples/typeinf.scala | |
parent | 73b2db5db4fc7316467b51299994b47065bde74d (diff) | |
download | scala-1f65685c9626929f3e6d7b81225f57fd4e68438c.tar.gz scala-1f65685c9626929f3e6d7b81225f57fd4e68438c.tar.bz2 scala-1f65685c9626929f3e6d7b81225f57fd4e68438c.zip |
updated examples
Diffstat (limited to 'docs/examples/typeinf.scala')
-rw-r--r-- | docs/examples/typeinf.scala | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/docs/examples/typeinf.scala b/docs/examples/typeinf.scala index da9ba9384c..80980ebc9a 100644 --- a/docs/examples/typeinf.scala +++ b/docs/examples/typeinf.scala @@ -32,7 +32,7 @@ case class Tycon(k: String, ts: List[Type]) extends Type { object typeInfer { private var n: Int = 0 - def newTyvar(): Type = { n = n + 1 ; Tyvar("a" + n) } + def newTyvar(): Type = { n += 1; Tyvar("a" + n) } trait Subst extends Function1[Type, Type] { def lookup(x: Tyvar): Type @@ -169,7 +169,7 @@ object typeInfer { /** Non-keyword identifiers */ def ident: Parser[String] = - for (s <- id; if s != "let" && s != "in") yield s + for (s <- id if s != "let" && s != "in") yield s /** term = '\' ident '.' term | term1 {term1} | let ident "=" term in term */ def term: Parser[Term] = ( @@ -181,7 +181,7 @@ object typeInfer { yield Lam(x, t): Term ) ||| ( for ( - letid <- id; if letid == "let"; + letid <- id if letid == "let"; x <- ident; _ <- wschr('='); t <- term; @@ -234,7 +234,7 @@ object typeInfer { "\n reason: " + msg } - def main(args: Array[String]): unit = + def main(args: Array[String]) { Console.println( if (args.length == 1) { val ps = new ParseString(args(0)) with MiniMLParsers @@ -248,5 +248,6 @@ object typeInfer { else "usage: java examples.typeinf <expr-string>" ) + } } |