diff options
author | Adam Chlipala <adam@chlipala.net> | 2011-07-15 18:55:58 -0400 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2011-07-15 18:55:58 -0400 |
commit | 5f5229381acb24b444f05513b0123ae62a5cb092 (patch) | |
tree | 12f8f5eac9e735909223542818bb3f9fefc70ef0 /doc/intro.ur | |
parent | 46b253e9a205802cd4503f2e4753b7a3002326ae (diff) |
Make 'static' protocol handle unlimited retry
Diffstat (limited to 'doc/intro.ur')
-rw-r--r-- | doc/intro.ur | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/doc/intro.ur b/doc/intro.ur index d474a1e1..b9b15b72 100644 --- a/doc/intro.ur +++ b/doc/intro.ur @@ -73,3 +73,22 @@ fun compose [a] [b] [c] (f : b -> c) (g : a -> b) (x : a) : c = f (g x) (* 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 *) |