comparison doc/intro.ur @ 1525:a479947efbcd

Improve detection of XML in urweb-mode; small tutorial improvement
author Adam Chlipala <adam@chlipala.net>
date Tue, 02 Aug 2011 17:28:37 -0400
parents 5616b2cbdcdb
children 2d9f831d45c9
comparison
equal deleted inserted replaced
1524:a71223513c77 1525:a479947efbcd
257 257
258 signature STACK = sig 258 signature STACK = sig
259 con t :: Type -> Type 259 con t :: Type -> Type
260 val empty : a ::: Type -> t a 260 val empty : a ::: Type -> t a
261 val push : a ::: Type -> t a -> a -> t a 261 val push : a ::: Type -> t a -> a -> t a
262 val pop : a ::: Type -> t a -> option a 262 val peek : a ::: Type -> t a -> option a
263 val pop : a ::: Type -> t a -> option (t a)
263 end 264 end
264 265
265 structure Stack : STACK = struct 266 structure Stack : STACK = struct
266 con t = list 267 con t = list
267 val empty [a] = [] 268 val empty [a] = []
268 fun push [a] (t : t a) (x : a) = x :: t 269 fun push [a] (t : t a) (x : a) = x :: t
270 fun peek [a] (t : t a) = case t of
271 [] => None
272 | x :: _ => Some x
269 fun pop [a] (t : t a) = case t of 273 fun pop [a] (t : t a) = case t of
270 [] => None 274 [] => None
271 | x :: _ => Some x 275 | _ :: t' => Some t'
272 end 276 end
273 277
274 (* begin eval *) 278 (* begin eval *)
275 Stack.pop (Stack.push (Stack.push Stack.empty "A") "B") 279 Stack.peek (Stack.push (Stack.push Stack.empty "A") "B")
276 (* end *) 280 (* end *)
277 281
278 (* Ur also inherits the ML concept of <b>functors</b>, which are functions from modules to modules. *) 282 (* Ur also inherits the ML concept of <b>functors</b>, which are functions from modules to modules. *)
279 283
280 datatype order = Less | Equal | Greater 284 datatype order = Less | Equal | Greater