Mercurial > urweb
diff doc/intro.ur @ 1498:8c32c7191bf0
Make 'static' protocol handle unlimited retry
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Fri, 15 Jul 2011 18:55:58 -0400 |
parents | 0b639858200b |
children | 92c929793d0f |
line wrap: on
line diff
--- a/doc/intro.ur Fri Jul 15 18:45:03 2011 -0400 +++ b/doc/intro.ur Fri Jul 15 18:55:58 2011 -0400 @@ -73,3 +73,22 @@ (* begin eval *) compose inc inc 3 (* end *) + +(* The "option" type family is like ML's "option" or Haskell's "maybe." Note that, while Ur follows most syntactic conventions of ML, one key difference is that type families appear before their arguments, as in Haskell. *) + +fun predecessor (n : int) : option int = if n >= 1 then Some (n - 1) else None + +(* begin hide *) +fun show_option [t] (_ : show t) : show (option t) = + mkShow (fn x => case x of + None => "None" + | Some x => "Some(" ^ show x ^ ")") +(* end *) + +(* begin eval *) +predecessor 6 +(* end *) + +(* begin eval *) +predecessor 0 +(* end *)