equal
deleted
inserted
replaced
35 type stamp |
35 type stamp |
36 val stamp: unit -> stamp |
36 val stamp: unit -> stamp |
37 |
37 |
38 (*options*) |
38 (*options*) |
39 val is_none: 'a option -> bool |
39 val is_none: 'a option -> bool |
|
40 |
|
41 (*old options -- invalidated*) |
|
42 datatype invalid = None of invalid |
|
43 exception OPTION of invalid |
|
44 |
40 exception ERROR |
45 exception ERROR |
41 val try: ('a -> 'b) -> 'a -> 'b option |
46 val try: ('a -> 'b) -> 'a -> 'b option |
42 val can: ('a -> 'b) -> 'a -> bool |
47 val can: ('a -> 'b) -> 'a -> bool |
43 datatype 'a result = Result of 'a | Exn of exn |
48 datatype 'a result = Result of 'a | Exn of exn |
44 val capture: ('a -> 'b) -> 'a -> 'b result |
49 val capture: ('a -> 'b) -> 'a -> 'b result |
315 |
320 |
316 |
321 |
317 (** options **) |
322 (** options **) |
318 |
323 |
319 val the = valOf; |
324 val the = valOf; |
320 |
325 fun if_none opt a = getOpt (opt, a); |
321 (*strict!*) |
|
322 fun if_none opt a = getOpt(opt,a); |
|
323 |
|
324 val is_some = isSome; |
326 val is_some = isSome; |
325 |
|
326 fun is_none opt = not (isSome opt); |
327 fun is_none opt = not (isSome opt); |
327 |
|
328 val apsome = Option.map; |
328 val apsome = Option.map; |
|
329 |
|
330 (*invalidate former constructors to prevent accidental use as match-all patterns!*) |
|
331 datatype invalid = None of invalid; |
|
332 exception OPTION of invalid; |
329 |
333 |
330 |
334 |
331 (* exception handling *) |
335 (* exception handling *) |
332 |
336 |
333 exception ERROR; |
337 exception ERROR; |
584 |
588 |
585 (* filter *) |
589 (* filter *) |
586 |
590 |
587 (*copy the list preserving elements that satisfy the predicate*) |
591 (*copy the list preserving elements that satisfy the predicate*) |
588 val filter = List.filter; |
592 val filter = List.filter; |
589 |
|
590 fun filter_out f = filter (not o f); |
593 fun filter_out f = filter (not o f); |
591 |
|
592 val mapfilter = List.mapPartial; |
594 val mapfilter = List.mapPartial; |
593 |
595 |
594 |
596 |
595 (* lists of pairs *) |
597 (* lists of pairs *) |
596 |
598 |