equal
deleted
inserted
replaced
1 (* Title: HOL/MiniML/Maybe.thy |
1 (* Title: HOL/MiniML/Maybe.thy |
2 ID: $Id$ |
2 ID: $Id$ |
3 Author: Dieter Nazareth and Tobias Nipkow |
3 Author: Wolfgang Naraschewski and Tobias Nipkow |
4 Copyright 1995 TU Muenchen |
4 Copyright 1996 TU Muenchen |
5 |
5 |
6 Universal error monad. |
6 Universal error monad. |
7 *) |
7 *) |
8 |
8 |
9 Maybe = List + |
9 Maybe = Option + List + |
10 |
|
11 datatype 'a maybe = Ok 'a | Fail |
|
12 |
10 |
13 constdefs |
11 constdefs |
14 bind :: ['a maybe, 'a => 'b maybe] => 'b maybe (infixl 60) |
12 option_bind :: ['a option, 'a => 'b option] => 'b option |
15 "m bind f == case m of Ok r => f r | Fail => Fail" |
13 "option_bind m f == case m of None => None | Some r => f r" |
16 |
14 |
17 syntax "@bind" :: [pttrns,'a maybe,'b] => 'c ("(_ := _;//_)" 0) |
15 syntax "@option_bind" :: [pttrns,'a option,'b] => 'c ("(_ := _;//_)" 0) |
18 translations "P := E; F" == "E bind (%P.F)" |
16 translations "P := E; F" == "option_bind E (%P.F)" |
19 |
17 |
20 end |
18 end |