Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 77 lines (62 sloc) 2.277 kb
fccc685 Initial open-source release
MLstate authored
1 /*
2 Copyright © 2011 MLstate
3
3143758 @Aqua-Ye [doc] lib: changed files headers to MIT license
Aqua-Ye authored
4 This file is part of Opa.
fccc685 Initial open-source release
MLstate authored
5
3143758 @Aqua-Ye [doc] lib: changed files headers to MIT license
Aqua-Ye authored
6 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
fccc685 Initial open-source release
MLstate authored
7
3143758 @Aqua-Ye [doc] lib: changed files headers to MIT license
Aqua-Ye authored
8 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
fccc685 Initial open-source release
MLstate authored
9
3143758 @Aqua-Ye [doc] lib: changed files headers to MIT license
Aqua-Ye authored
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
fccc685 Initial open-source release
MLstate authored
11 */
62c92c3 [doc] review: Review of stdlib.core
Guillem Rieu authored
12
fccc685 Initial open-source release
MLstate authored
13 /**
14 * Basic functions on booleans.
15 *
16 * @category data
17 * @destination public
18 * @author David Rajchenbach-Teller, 2010 (documentation)
19 * @stability stable
20 */
21
22 /**
62c92c3 [doc] review: Review of stdlib.core
Guillem Rieu authored
23 * {1 About this module}
24 *
25 * {1 Where should I start?}
26 *
27 * {1 What if I need more?}
28 */
29
30 /**
31 * {1 Types defined in this module}
32 */
33
34 /**
fccc685 Initial open-source release
MLstate authored
35 * Order type label for bool
36 */
37 type Bool.order = Order.default
38
62c92c3 [doc] review: Review of stdlib.core
Guillem Rieu authored
39 /**
40 * {1 Interface}
41 */
42
fccc685 Initial open-source release
MLstate authored
43 Bool =
44 {{
45 /**
46 * Convert a boolean to a string representation.
47 *
48 * @return ["true"] or ["false"]
49 */
50 @stringifier(bool) to_string(b: bool) = if b then "true" else "false"
51
52 /**
53 * Convert a string to a boolean representation.
54 */
55 of_string =
56 | "true" -> some(true)
57 | "false" -> some(false)
58 | _ -> none
59
60 /**
61 * Order on boolean values ([false] < [true])
62 */
63 order = Order.make(ordering) : order(bool, Bool.order)
64
65 /**
66 * Comparing boolean values ([false] < [true])
67 */
68 ordering(b1, b2) : Order.ordering =
69 // TODO: Do we want BSL for that? Guess not...
70 match (b1: bool, b2: bool) with
71 | ({false}, {true}) -> {lt}
72 | ({true}, {false}) -> {gt}
73 | ({false}, {false})
74 | ({true}, {true}) -> {eq}
75
76 }}
Something went wrong with that request. Please try again.