ic-mops 0.8.5 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -1
- package/.mops/base@0.7.4/LICENSE +0 -208
- package/.mops/base@0.7.4/README.md +0 -64
- package/.mops/base@0.7.4/mops.toml +0 -5
- package/.mops/base@0.7.4/src/Array.mo +0 -686
- package/.mops/base@0.7.4/src/AssocList.mo +0 -203
- package/.mops/base@0.7.4/src/Blob.mo +0 -55
- package/.mops/base@0.7.4/src/Bool.mo +0 -44
- package/.mops/base@0.7.4/src/Buffer.mo +0 -1937
- package/.mops/base@0.7.4/src/CertifiedData.mo +0 -29
- package/.mops/base@0.7.4/src/Char.mo +0 -67
- package/.mops/base@0.7.4/src/Debug.mo +0 -15
- package/.mops/base@0.7.4/src/Deque.mo +0 -75
- package/.mops/base@0.7.4/src/Error.mo +0 -41
- package/.mops/base@0.7.4/src/ExperimentalCycles.mo +0 -51
- package/.mops/base@0.7.4/src/ExperimentalInternetComputer.mo +0 -36
- package/.mops/base@0.7.4/src/ExperimentalStableMemory.mo +0 -121
- package/.mops/base@0.7.4/src/Float.mo +0 -150
- package/.mops/base@0.7.4/src/Func.mo +0 -38
- package/.mops/base@0.7.4/src/Hash.mo +0 -83
- package/.mops/base@0.7.4/src/HashMap.mo +0 -229
- package/.mops/base@0.7.4/src/Heap.mo +0 -113
- package/.mops/base@0.7.4/src/Int.mo +0 -150
- package/.mops/base@0.7.4/src/Int16.mo +0 -159
- package/.mops/base@0.7.4/src/Int32.mo +0 -160
- package/.mops/base@0.7.4/src/Int64.mo +0 -161
- package/.mops/base@0.7.4/src/Int8.mo +0 -160
- package/.mops/base@0.7.4/src/Iter.mo +0 -220
- package/.mops/base@0.7.4/src/IterType.mo +0 -7
- package/.mops/base@0.7.4/src/List.mo +0 -433
- package/.mops/base@0.7.4/src/Nat.mo +0 -75
- package/.mops/base@0.7.4/src/Nat16.mo +0 -146
- package/.mops/base@0.7.4/src/Nat32.mo +0 -146
- package/.mops/base@0.7.4/src/Nat64.mo +0 -146
- package/.mops/base@0.7.4/src/Nat8.mo +0 -146
- package/.mops/base@0.7.4/src/None.mo +0 -19
- package/.mops/base@0.7.4/src/Option.mo +0 -160
- package/.mops/base@0.7.4/src/Order.mo +0 -46
- package/.mops/base@0.7.4/src/Prelude.mo +0 -33
- package/.mops/base@0.7.4/src/Principal.mo +0 -58
- package/.mops/base@0.7.4/src/RBTree.mo +0 -218
- package/.mops/base@0.7.4/src/Random.mo +0 -188
- package/.mops/base@0.7.4/src/Result.mo +0 -210
- package/.mops/base@0.7.4/src/Stack.mo +0 -40
- package/.mops/base@0.7.4/src/Text.mo +0 -615
- package/.mops/base@0.7.4/src/Time.mo +0 -37
- package/.mops/base@0.7.4/src/Trie.mo +0 -1200
- package/.mops/base@0.7.4/src/TrieMap.mo +0 -180
- package/.mops/base@0.7.4/src/TrieSet.mo +0 -97
- package/.mops/base@0.8.3/LICENSE +0 -208
- package/.mops/base@0.8.3/README.md +0 -64
- package/.mops/base@0.8.3/mops.toml +0 -6
- package/.mops/base@0.8.3/src/Array.mo +0 -717
- package/.mops/base@0.8.3/src/AssocList.mo +0 -404
- package/.mops/base@0.8.3/src/Blob.mo +0 -212
- package/.mops/base@0.8.3/src/Bool.mo +0 -44
- package/.mops/base@0.8.3/src/Buffer.mo +0 -2660
- package/.mops/base@0.8.3/src/CertifiedData.mo +0 -53
- package/.mops/base@0.8.3/src/Char.mo +0 -65
- package/.mops/base@0.8.3/src/Debug.mo +0 -56
- package/.mops/base@0.8.3/src/Deque.mo +0 -243
- package/.mops/base@0.8.3/src/Error.mo +0 -68
- package/.mops/base@0.8.3/src/ExperimentalCycles.mo +0 -151
- package/.mops/base@0.8.3/src/ExperimentalInternetComputer.mo +0 -60
- package/.mops/base@0.8.3/src/ExperimentalStableMemory.mo +0 -348
- package/.mops/base@0.8.3/src/Float.mo +0 -843
- package/.mops/base@0.8.3/src/Func.mo +0 -46
- package/.mops/base@0.8.3/src/Hash.mo +0 -82
- package/.mops/base@0.8.3/src/HashMap.mo +0 -457
- package/.mops/base@0.8.3/src/Heap.mo +0 -233
- package/.mops/base@0.8.3/src/Int.mo +0 -365
- package/.mops/base@0.8.3/src/Int16.mo +0 -521
- package/.mops/base@0.8.3/src/Int32.mo +0 -522
- package/.mops/base@0.8.3/src/Int64.mo +0 -522
- package/.mops/base@0.8.3/src/Int8.mo +0 -522
- package/.mops/base@0.8.3/src/Iter.mo +0 -227
- package/.mops/base@0.8.3/src/IterType.mo +0 -7
- package/.mops/base@0.8.3/src/List.mo +0 -930
- package/.mops/base@0.8.3/src/Nat.mo +0 -305
- package/.mops/base@0.8.3/src/Nat16.mo +0 -144
- package/.mops/base@0.8.3/src/Nat32.mo +0 -144
- package/.mops/base@0.8.3/src/Nat64.mo +0 -144
- package/.mops/base@0.8.3/src/Nat8.mo +0 -144
- package/.mops/base@0.8.3/src/None.mo +0 -19
- package/.mops/base@0.8.3/src/Option.mo +0 -154
- package/.mops/base@0.8.3/src/Order.mo +0 -46
- package/.mops/base@0.8.3/src/Prelude.mo +0 -33
- package/.mops/base@0.8.3/src/Principal.mo +0 -249
- package/.mops/base@0.8.3/src/RBTree.mo +0 -681
- package/.mops/base@0.8.3/src/Random.mo +0 -270
- package/.mops/base@0.8.3/src/Result.mo +0 -209
- package/.mops/base@0.8.3/src/Stack.mo +0 -93
- package/.mops/base@0.8.3/src/Text.mo +0 -761
- package/.mops/base@0.8.3/src/Time.mo +0 -36
- package/.mops/base@0.8.3/src/Timer.mo +0 -62
- package/.mops/base@0.8.3/src/Trie.mo +0 -1603
- package/.mops/base@0.8.3/src/TrieMap.mo +0 -392
- package/.mops/base@0.8.3/src/TrieSet.mo +0 -148
- package/network.txt +0 -1
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/// Natural numbers
|
|
2
|
-
///
|
|
3
|
-
/// Most operations on natural numbers (e.g. addition) are available as built-in operators (e.g. `1 + 1`).
|
|
4
|
-
/// This module provides equivalent functions and `Text` conversion.
|
|
5
|
-
|
|
6
|
-
import Int "Int";
|
|
7
|
-
import Order "Order";
|
|
8
|
-
import Prim "mo:⛔";
|
|
9
|
-
|
|
10
|
-
module {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/// Infinite precision natural numbers.
|
|
14
|
-
public type Nat = Prim.Types.Nat;
|
|
15
|
-
|
|
16
|
-
/// Conversion.
|
|
17
|
-
public let toText : Nat -> Text = Int.toText;
|
|
18
|
-
|
|
19
|
-
/// Returns the minimum of `x` and `y`.
|
|
20
|
-
public func min(x : Nat, y : Nat) : Nat {
|
|
21
|
-
if (x < y) { x } else { y }
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/// Returns the maximum of `x` and `y`.
|
|
25
|
-
public func max( x : Nat, y : Nat) : Nat {
|
|
26
|
-
if (x < y) { y } else { x }
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/// Returns `x == y`.
|
|
30
|
-
public func equal(x : Nat, y : Nat) : Bool { x == y };
|
|
31
|
-
|
|
32
|
-
/// Returns `x != y`.
|
|
33
|
-
public func notEqual(x : Nat, y : Nat) : Bool { x != y };
|
|
34
|
-
|
|
35
|
-
/// Returns `x < y`.
|
|
36
|
-
public func less(x : Nat, y : Nat) : Bool { x < y };
|
|
37
|
-
|
|
38
|
-
/// Returns `x <= y`.
|
|
39
|
-
public func lessOrEqual(x : Nat, y : Nat) : Bool { x <= y };
|
|
40
|
-
|
|
41
|
-
/// Returns `x > y`.
|
|
42
|
-
public func greater(x : Nat, y : Nat) : Bool { x > y };
|
|
43
|
-
|
|
44
|
-
/// Returns `x >= y`.
|
|
45
|
-
public func greaterOrEqual(x : Nat, y : Nat) : Bool { x >= y };
|
|
46
|
-
|
|
47
|
-
/// Returns the order of `x` and `y`.
|
|
48
|
-
public func compare(x : Nat, y : Nat) : { #less; #equal; #greater } {
|
|
49
|
-
if (x < y) { #less }
|
|
50
|
-
else if (x == y) { #equal }
|
|
51
|
-
else { #greater }
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/// Returns the sum of `x` and `y`, `x + y`.
|
|
55
|
-
public func add(x : Nat, y : Nat) : Nat { x + y };
|
|
56
|
-
|
|
57
|
-
/// Returns the difference of `x` and `y`, `x - y`.
|
|
58
|
-
/// Traps on underflow.
|
|
59
|
-
public func sub(x : Nat, y : Nat) : Nat { x - y };
|
|
60
|
-
|
|
61
|
-
/// Returns the product of `x` and `y`, `x * y`.
|
|
62
|
-
public func mul(x : Nat, y : Nat) : Nat { x * y };
|
|
63
|
-
|
|
64
|
-
/// Returns the division of `x` by `y`, `x / y`.
|
|
65
|
-
/// Traps when `y` is zero.
|
|
66
|
-
public func div(x : Nat, y : Nat) : Nat { x / y };
|
|
67
|
-
|
|
68
|
-
/// Returns the remainder of `x` divided by `y`, `x % y`.
|
|
69
|
-
/// Traps when `y` is zero.
|
|
70
|
-
public func rem(x : Nat, y : Nat) : Nat { x % y };
|
|
71
|
-
|
|
72
|
-
/// Returns `x` to the power of `y`, `x ** y`.
|
|
73
|
-
public func pow(x : Nat, y : Nat) : Nat { x ** y };
|
|
74
|
-
|
|
75
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/// 16-bit unsigned integers with checked arithmetic
|
|
2
|
-
///
|
|
3
|
-
/// Most operations are available as built-in operators (e.g. `1 + 1`).
|
|
4
|
-
import Nat "Nat";
|
|
5
|
-
import Prim "mo:⛔";
|
|
6
|
-
|
|
7
|
-
module {
|
|
8
|
-
|
|
9
|
-
/// 16-bit natural numbers.
|
|
10
|
-
public type Nat16 = Prim.Types.Nat16;
|
|
11
|
-
|
|
12
|
-
/// Conversion.
|
|
13
|
-
public let toNat : Nat16 -> Nat = Prim.nat16ToNat;
|
|
14
|
-
|
|
15
|
-
/// Conversion. Traps on overflow/underflow.
|
|
16
|
-
public let fromNat : Nat -> Nat16 = Prim.natToNat16;
|
|
17
|
-
|
|
18
|
-
/// Conversion. Wraps on overflow/underflow.
|
|
19
|
-
public let fromIntWrap : Int -> Nat16 = Prim.intToNat16Wrap;
|
|
20
|
-
|
|
21
|
-
/// Returns the Text representation of `x`.
|
|
22
|
-
public func toText(x : Nat16) : Text {
|
|
23
|
-
Nat.toText(toNat(x))
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/// Returns the minimum of `x` and `y`.
|
|
27
|
-
public func min(x : Nat16, y : Nat16) : Nat16 {
|
|
28
|
-
if (x < y) { x } else { y }
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/// Returns the maximum of `x` and `y`.
|
|
32
|
-
public func max( x : Nat16, y : Nat16) : Nat16 {
|
|
33
|
-
if (x < y) { y } else { x }
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/// Returns `x == y`.
|
|
37
|
-
public func equal(x : Nat16, y : Nat16) : Bool { x == y };
|
|
38
|
-
|
|
39
|
-
/// Returns `x != y`.
|
|
40
|
-
public func notEqual(x : Nat16, y : Nat16) : Bool { x != y };
|
|
41
|
-
|
|
42
|
-
/// Returns `x < y`.
|
|
43
|
-
public func less(x : Nat16, y : Nat16) : Bool { x < y };
|
|
44
|
-
|
|
45
|
-
/// Returns `x <= y`.
|
|
46
|
-
public func lessOrEqual(x : Nat16, y : Nat16) : Bool { x <= y };
|
|
47
|
-
|
|
48
|
-
/// Returns `x > y`.
|
|
49
|
-
public func greater(x : Nat16, y : Nat16) : Bool { x > y };
|
|
50
|
-
|
|
51
|
-
/// Returns `x >= y`.
|
|
52
|
-
public func greaterOrEqual(x : Nat16, y : Nat16) : Bool { x >= y };
|
|
53
|
-
|
|
54
|
-
/// Returns the order of `x` and `y`.
|
|
55
|
-
public func compare(x : Nat16, y : Nat16) : { #less; #equal; #greater } {
|
|
56
|
-
if (x < y) { #less }
|
|
57
|
-
else if (x == y) { #equal }
|
|
58
|
-
else { #greater }
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/// Returns the sum of `x` and `y`, `x + y`. Traps on overflow.
|
|
62
|
-
public func add(x : Nat16, y : Nat16) : Nat16 { x + y };
|
|
63
|
-
|
|
64
|
-
/// Returns the difference of `x` and `y`, `x - y`. Traps on underflow.
|
|
65
|
-
public func sub(x : Nat16, y : Nat16) : Nat16 { x - y };
|
|
66
|
-
|
|
67
|
-
/// Returns the product of `x` and `y`, `x * y`. Traps on overflow.
|
|
68
|
-
public func mul(x : Nat16, y : Nat16) : Nat16 { x * y };
|
|
69
|
-
|
|
70
|
-
/// Returns the division of `x by y`, `x / y`.
|
|
71
|
-
/// Traps when `y` is zero.
|
|
72
|
-
public func div(x : Nat16, y : Nat16) : Nat16 { x / y };
|
|
73
|
-
|
|
74
|
-
/// Returns the remainder of `x` divided by `y`, `x % y`.
|
|
75
|
-
/// Traps when `y` is zero.
|
|
76
|
-
public func rem(x : Nat16, y : Nat16) : Nat16 { x % y };
|
|
77
|
-
|
|
78
|
-
/// Returns `x` to the power of `y`, `x ** y`. Traps on overflow.
|
|
79
|
-
public func pow(x : Nat16, y : Nat16) : Nat16 { x ** y };
|
|
80
|
-
|
|
81
|
-
/// Returns the bitwise negation of `x`, `^x`.
|
|
82
|
-
public func bitnot(x : Nat16, y : Nat16) : Nat16 { ^x };
|
|
83
|
-
|
|
84
|
-
/// Returns the bitwise and of `x` and `y`, `x & y`.
|
|
85
|
-
public func bitand(x : Nat16, y : Nat16) : Nat16 { x & y };
|
|
86
|
-
|
|
87
|
-
/// Returns the bitwise or of `x` and `y`, `x \| y`.
|
|
88
|
-
public func bitor(x : Nat16, y : Nat16) : Nat16 { x | y };
|
|
89
|
-
|
|
90
|
-
/// Returns the bitwise exclusive or of `x` and `y`, `x ^ y`.
|
|
91
|
-
public func bitxor(x : Nat16, y : Nat16) : Nat16 { x ^ y };
|
|
92
|
-
|
|
93
|
-
/// Returns the bitwise shift left of `x` by `y`, `x << y`.
|
|
94
|
-
public func bitshiftLeft(x : Nat16, y : Nat16) : Nat16 { x << y };
|
|
95
|
-
|
|
96
|
-
/// Returns the bitwise shift right of `x` by `y`, `x >> y`.
|
|
97
|
-
public func bitshiftRight(x : Nat16, y : Nat16) : Nat16 { x >> y };
|
|
98
|
-
|
|
99
|
-
/// Returns the bitwise rotate left of `x` by `y`, `x <<> y`.
|
|
100
|
-
public func bitrotLeft(x : Nat16, y : Nat16) : Nat16 { x <<> y };
|
|
101
|
-
|
|
102
|
-
/// Returns the bitwise rotate right of `x` by `y`, `x <>> y`.
|
|
103
|
-
public func bitrotRight(x : Nat16, y : Nat16) : Nat16 { x <>> y };
|
|
104
|
-
|
|
105
|
-
/// Returns the value of bit `p mod 16` in `x`, `(x & 2^(p mod 16)) == 2^(p mod 16)`.
|
|
106
|
-
public func bittest(x : Nat16, p : Nat) : Bool {
|
|
107
|
-
Prim.btstNat16(x, Prim.natToNat16(p));
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
/// Returns the value of setting bit `p mod 16` in `x` to `1`.
|
|
111
|
-
public func bitset(x : Nat16, p : Nat) : Nat16 {
|
|
112
|
-
x | (1 << Prim.natToNat16(p));
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
/// Returns the value of clearing bit `p mod 16` in `x` to `0`.
|
|
116
|
-
public func bitclear(x : Nat16, p : Nat) : Nat16 {
|
|
117
|
-
x & ^(1 << Prim.natToNat16(p));
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/// Returns the value of flipping bit `p mod 16` in `x`.
|
|
121
|
-
public func bitflip(x : Nat16, p : Nat) : Nat16 {
|
|
122
|
-
x ^ (1 << Prim.natToNat16(p));
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/// Returns the count of non-zero bits in `x`.
|
|
126
|
-
public let bitcountNonZero : (x : Nat16) -> Nat16 = Prim.popcntNat16;
|
|
127
|
-
|
|
128
|
-
/// Returns the count of leading zero bits in `x`.
|
|
129
|
-
public let bitcountLeadingZero : (x : Nat16) -> Nat16 = Prim.clzNat16;
|
|
130
|
-
|
|
131
|
-
/// Returns the count of trailing zero bits in `x`.
|
|
132
|
-
public let bitcountTrailingZero : (x : Nat16) -> Nat16 = Prim.ctzNat16;
|
|
133
|
-
|
|
134
|
-
/// Returns the sum of `x` and `y`, `x +% y`. Wraps on overflow.
|
|
135
|
-
public func addWrap(x : Nat16, y : Nat16) : Nat16 { x +% y };
|
|
136
|
-
|
|
137
|
-
/// Returns the difference of `x` and `y`, `x -% y`. Wraps on underflow.
|
|
138
|
-
public func subWrap(x : Nat16, y : Nat16) : Nat16 { x -% y };
|
|
139
|
-
|
|
140
|
-
/// Returns the product of `x` and `y`, `x *% y`. Wraps on overflow.
|
|
141
|
-
public func mulWrap(x : Nat16, y : Nat16) : Nat16 { x *% y };
|
|
142
|
-
|
|
143
|
-
/// Returns `x` to the power of `y`, `x **% y`. Wraps on overflow.
|
|
144
|
-
public func powWrap(x : Nat16, y : Nat16) : Nat16 { x **% y };
|
|
145
|
-
|
|
146
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/// 32-bit unsigned integers with checked arithmetic
|
|
2
|
-
///
|
|
3
|
-
/// Most operations are available as built-in operators (e.g. `1 + 1`).
|
|
4
|
-
import Nat "Nat";
|
|
5
|
-
import Prim "mo:⛔";
|
|
6
|
-
|
|
7
|
-
module {
|
|
8
|
-
|
|
9
|
-
/// 32-bit natural numbers.
|
|
10
|
-
public type Nat32 = Prim.Types.Nat32;
|
|
11
|
-
|
|
12
|
-
/// Conversion.
|
|
13
|
-
public let toNat : Nat32 -> Nat = Prim.nat32ToNat;
|
|
14
|
-
|
|
15
|
-
/// Conversion. Traps on overflow/underflow.
|
|
16
|
-
public let fromNat : Nat -> Nat32 = Prim.natToNat32;
|
|
17
|
-
|
|
18
|
-
/// Conversion. Wraps on overflow/underflow.
|
|
19
|
-
public let fromIntWrap : Int -> Nat32 = Prim.intToNat32Wrap;
|
|
20
|
-
|
|
21
|
-
/// Returns the Text representation of `x`.
|
|
22
|
-
public func toText(x : Nat32) : Text {
|
|
23
|
-
Nat.toText(toNat(x))
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/// Returns the minimum of `x` and `y`.
|
|
27
|
-
public func min(x : Nat32, y : Nat32) : Nat32 {
|
|
28
|
-
if (x < y) { x } else { y }
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/// Returns the maximum of `x` and `y`.
|
|
32
|
-
public func max( x : Nat32, y : Nat32) : Nat32 {
|
|
33
|
-
if (x < y) { y } else { x }
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/// Returns `x == y`.
|
|
37
|
-
public func equal(x : Nat32, y : Nat32) : Bool { x == y };
|
|
38
|
-
|
|
39
|
-
/// Returns `x != y`.
|
|
40
|
-
public func notEqual(x : Nat32, y : Nat32) : Bool { x != y };
|
|
41
|
-
|
|
42
|
-
/// Returns `x < y`.
|
|
43
|
-
public func less(x : Nat32, y : Nat32) : Bool { x < y };
|
|
44
|
-
|
|
45
|
-
/// Returns `x <= y`.
|
|
46
|
-
public func lessOrEqual(x : Nat32, y : Nat32) : Bool { x <= y };
|
|
47
|
-
|
|
48
|
-
/// Returns `x > y`.
|
|
49
|
-
public func greater(x : Nat32, y : Nat32) : Bool { x > y };
|
|
50
|
-
|
|
51
|
-
/// Returns `x >= y`.
|
|
52
|
-
public func greaterOrEqual(x : Nat32, y : Nat32) : Bool { x >= y };
|
|
53
|
-
|
|
54
|
-
/// Returns the order of `x` and `y`.
|
|
55
|
-
public func compare(x : Nat32, y : Nat32) : { #less; #equal; #greater } {
|
|
56
|
-
if (x < y) { #less }
|
|
57
|
-
else if (x == y) { #equal }
|
|
58
|
-
else { #greater }
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/// Returns the sum of `x` and `y`, `x + y`. Traps on overflow.
|
|
62
|
-
public func add(x : Nat32, y : Nat32) : Nat32 { x + y };
|
|
63
|
-
|
|
64
|
-
/// Returns the difference of `x` and `y`, `x - y`. Traps on underflow.
|
|
65
|
-
public func sub(x : Nat32, y : Nat32) : Nat32 { x - y };
|
|
66
|
-
|
|
67
|
-
/// Returns the product of `x` and `y`, `x * y`. Traps on overflow.
|
|
68
|
-
public func mul(x : Nat32, y : Nat32) : Nat32 { x * y };
|
|
69
|
-
|
|
70
|
-
/// Returns the division of `x by y`, `x / y`.
|
|
71
|
-
/// Traps when `y` is zero.
|
|
72
|
-
public func div(x : Nat32, y : Nat32) : Nat32 { x / y };
|
|
73
|
-
|
|
74
|
-
/// Returns the remainder of `x` divided by `y`, `x % y`.
|
|
75
|
-
/// Traps when `y` is zero.
|
|
76
|
-
public func rem(x : Nat32, y : Nat32) : Nat32 { x % y };
|
|
77
|
-
|
|
78
|
-
/// Returns `x` to the power of `y`, `x ** y`. Traps on overflow.
|
|
79
|
-
public func pow(x : Nat32, y : Nat32) : Nat32 { x ** y };
|
|
80
|
-
|
|
81
|
-
/// Returns the bitwise negation of `x`, `^x`.
|
|
82
|
-
public func bitnot(x : Nat32, y : Nat32) : Nat32 { ^x };
|
|
83
|
-
|
|
84
|
-
/// Returns the bitwise and of `x` and `y`, `x & y`.
|
|
85
|
-
public func bitand(x : Nat32, y : Nat32) : Nat32 { x & y };
|
|
86
|
-
|
|
87
|
-
/// Returns the bitwise or of `x` and `y`, `x \| y`.
|
|
88
|
-
public func bitor(x : Nat32, y : Nat32) : Nat32 { x | y };
|
|
89
|
-
|
|
90
|
-
/// Returns the bitwise exclusive or of `x` and `y`, `x ^ y`.
|
|
91
|
-
public func bitxor(x : Nat32, y : Nat32) : Nat32 { x ^ y };
|
|
92
|
-
|
|
93
|
-
/// Returns the bitwise shift left of `x` by `y`, `x << y`.
|
|
94
|
-
public func bitshiftLeft(x : Nat32, y : Nat32) : Nat32 { x << y };
|
|
95
|
-
|
|
96
|
-
/// Returns the bitwise shift right of `x` by `y`, `x >> y`.
|
|
97
|
-
public func bitshiftRight(x : Nat32, y : Nat32) : Nat32 { x >> y };
|
|
98
|
-
|
|
99
|
-
/// Returns the bitwise rotate left of `x` by `y`, `x <<> y`.
|
|
100
|
-
public func bitrotLeft(x : Nat32, y : Nat32) : Nat32 { x <<> y };
|
|
101
|
-
|
|
102
|
-
/// Returns the bitwise rotate right of `x` by `y`, `x <>> y`.
|
|
103
|
-
public func bitrotRight(x : Nat32, y : Nat32) : Nat32 { x <>> y };
|
|
104
|
-
|
|
105
|
-
/// Returns the value of bit `p mod 32` in `x`, `(x & 2^(p mod 32)) == 2^(p mod 32)`.
|
|
106
|
-
public func bittest(x : Nat32, p : Nat) : Bool {
|
|
107
|
-
Prim.btstNat32(x, Prim.natToNat32(p));
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
/// Returns the value of setting bit `p mod 32` in `x` to `1`.
|
|
111
|
-
public func bitset(x : Nat32, p : Nat) : Nat32 {
|
|
112
|
-
x | (1 << Prim.natToNat32(p));
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
/// Returns the value of clearing bit `p mod 32` in `x` to `0`.
|
|
116
|
-
public func bitclear(x : Nat32, p : Nat) : Nat32 {
|
|
117
|
-
x & ^(1 << Prim.natToNat32(p));
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/// Returns the value of flipping bit `p mod 32` in `x`.
|
|
121
|
-
public func bitflip(x : Nat32, p : Nat) : Nat32 {
|
|
122
|
-
x ^ (1 << Prim.natToNat32(p));
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/// Returns the count of non-zero bits in `x`.
|
|
126
|
-
public let bitcountNonZero : (x : Nat32) -> Nat32 = Prim.popcntNat32;
|
|
127
|
-
|
|
128
|
-
/// Returns the count of leading zero bits in `x`.
|
|
129
|
-
public let bitcountLeadingZero : (x : Nat32) -> Nat32 = Prim.clzNat32;
|
|
130
|
-
|
|
131
|
-
/// Returns the count of trailing zero bits in `x`.
|
|
132
|
-
public let bitcountTrailingZero : (x : Nat32) -> Nat32 = Prim.ctzNat32;
|
|
133
|
-
|
|
134
|
-
/// Returns the sum of `x` and `y`, `x +% y`. Wraps on overflow.
|
|
135
|
-
public func addWrap(x : Nat32, y : Nat32) : Nat32 { x +% y };
|
|
136
|
-
|
|
137
|
-
/// Returns the difference of `x` and `y`, `x -% y`. Wraps on underflow.
|
|
138
|
-
public func subWrap(x : Nat32, y : Nat32) : Nat32 { x -% y };
|
|
139
|
-
|
|
140
|
-
/// Returns the product of `x` and `y`, `x *% y`. Wraps on overflow.
|
|
141
|
-
public func mulWrap(x : Nat32, y : Nat32) : Nat32 { x *% y };
|
|
142
|
-
|
|
143
|
-
/// Returns `x` to the power of `y`, `x **% y`. Wraps on overflow.
|
|
144
|
-
public func powWrap(x : Nat32, y : Nat32) : Nat32 { x **% y };
|
|
145
|
-
|
|
146
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/// 64-bit unsigned integers with checked arithmetic
|
|
2
|
-
///
|
|
3
|
-
/// Most operations are available as built-in operators (e.g. `1 + 1`).
|
|
4
|
-
import Nat "Nat";
|
|
5
|
-
import Prim "mo:⛔";
|
|
6
|
-
|
|
7
|
-
module {
|
|
8
|
-
|
|
9
|
-
/// 64-bit natural numbers.
|
|
10
|
-
public type Nat64 = Prim.Types.Nat64;
|
|
11
|
-
|
|
12
|
-
/// Conversion.
|
|
13
|
-
public let toNat : Nat64 -> Nat = Prim.nat64ToNat;
|
|
14
|
-
|
|
15
|
-
/// Conversion. Traps on overflow/underflow.
|
|
16
|
-
public let fromNat : Nat -> Nat64 = Prim.natToNat64;
|
|
17
|
-
|
|
18
|
-
/// Conversion. Wraps on overflow/underflow.
|
|
19
|
-
public let fromIntWrap : Int -> Nat64 = Prim.intToNat64Wrap;
|
|
20
|
-
|
|
21
|
-
/// Returns the Text representation of `x`.
|
|
22
|
-
public func toText(x : Nat64) : Text {
|
|
23
|
-
Nat.toText(toNat(x))
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/// Returns the minimum of `x` and `y`.
|
|
27
|
-
public func min(x : Nat64, y : Nat64) : Nat64 {
|
|
28
|
-
if (x < y) { x } else { y }
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/// Returns the maximum of `x` and `y`.
|
|
32
|
-
public func max( x : Nat64, y : Nat64) : Nat64 {
|
|
33
|
-
if (x < y) { y } else { x }
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/// Returns `x == y`.
|
|
37
|
-
public func equal(x : Nat64, y : Nat64) : Bool { x == y };
|
|
38
|
-
|
|
39
|
-
/// Returns `x != y`.
|
|
40
|
-
public func notEqual(x : Nat64, y : Nat64) : Bool { x != y };
|
|
41
|
-
|
|
42
|
-
/// Returns `x < y`.
|
|
43
|
-
public func less(x : Nat64, y : Nat64) : Bool { x < y };
|
|
44
|
-
|
|
45
|
-
/// Returns `x <= y`.
|
|
46
|
-
public func lessOrEqual(x : Nat64, y : Nat64) : Bool { x <= y };
|
|
47
|
-
|
|
48
|
-
/// Returns `x > y`.
|
|
49
|
-
public func greater(x : Nat64, y : Nat64) : Bool { x > y };
|
|
50
|
-
|
|
51
|
-
/// Returns `x >= y`.
|
|
52
|
-
public func greaterOrEqual(x : Nat64, y : Nat64) : Bool { x >= y };
|
|
53
|
-
|
|
54
|
-
/// Returns the order of `x` and `y`.
|
|
55
|
-
public func compare(x : Nat64, y : Nat64) : { #less; #equal; #greater } {
|
|
56
|
-
if (x < y) { #less }
|
|
57
|
-
else if (x == y) { #equal }
|
|
58
|
-
else { #greater }
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/// Returns the sum of `x` and `y`, `x + y`. Traps on overflow.
|
|
62
|
-
public func add(x : Nat64, y : Nat64) : Nat64 { x + y };
|
|
63
|
-
|
|
64
|
-
/// Returns the difference of `x` and `y`, `x - y`. Traps on underflow.
|
|
65
|
-
public func sub(x : Nat64, y : Nat64) : Nat64 { x - y };
|
|
66
|
-
|
|
67
|
-
/// Returns the product of `x` and `y`, `x * y`. Traps on overflow.
|
|
68
|
-
public func mul(x : Nat64, y : Nat64) : Nat64 { x * y };
|
|
69
|
-
|
|
70
|
-
/// Returns the division of `x by y`, `x / y`.
|
|
71
|
-
/// Traps when `y` is zero.
|
|
72
|
-
public func div(x : Nat64, y : Nat64) : Nat64 { x / y };
|
|
73
|
-
|
|
74
|
-
/// Returns the remainder of `x` divided by `y`, `x % y`.
|
|
75
|
-
/// Traps when `y` is zero.
|
|
76
|
-
public func rem(x : Nat64, y : Nat64) : Nat64 { x % y };
|
|
77
|
-
|
|
78
|
-
/// Returns `x` to the power of `y`, `x ** y`. Traps on overflow.
|
|
79
|
-
public func pow(x : Nat64, y : Nat64) : Nat64 { x ** y };
|
|
80
|
-
|
|
81
|
-
/// Returns the bitwise negation of `x`, `^x`.
|
|
82
|
-
public func bitnot(x : Nat64, y : Nat64) : Nat64 { ^x };
|
|
83
|
-
|
|
84
|
-
/// Returns the bitwise and of `x` and `y`, `x & y`.
|
|
85
|
-
public func bitand(x : Nat64, y : Nat64) : Nat64 { x & y };
|
|
86
|
-
|
|
87
|
-
/// Returns the bitwise or of `x` and `y`, `x \| y`.
|
|
88
|
-
public func bitor(x : Nat64, y : Nat64) : Nat64 { x | y };
|
|
89
|
-
|
|
90
|
-
/// Returns the bitwise exclusive or of `x` and `y`, `x ^ y`.
|
|
91
|
-
public func bitxor(x : Nat64, y : Nat64) : Nat64 { x ^ y };
|
|
92
|
-
|
|
93
|
-
/// Returns the bitwise shift left of `x` by `y`, `x << y`.
|
|
94
|
-
public func bitshiftLeft(x : Nat64, y : Nat64) : Nat64 { x << y };
|
|
95
|
-
|
|
96
|
-
/// Returns the bitwise shift right of `x` by `y`, `x >> y`.
|
|
97
|
-
public func bitshiftRight(x : Nat64, y : Nat64) : Nat64 { x >> y };
|
|
98
|
-
|
|
99
|
-
/// Returns the bitwise rotate left of `x` by `y`, `x <<> y`.
|
|
100
|
-
public func bitrotLeft(x : Nat64, y : Nat64) : Nat64 { x <<> y };
|
|
101
|
-
|
|
102
|
-
/// Returns the bitwise rotate right of `x` by `y`, `x <>> y`.
|
|
103
|
-
public func bitrotRight(x : Nat64, y : Nat64) : Nat64 { x <>> y };
|
|
104
|
-
|
|
105
|
-
/// Returns the value of bit `p mod 64` in `x`, `(x & 2^(p mod 64)) == 2^(p mod 64)`.
|
|
106
|
-
public func bittest(x : Nat64, p : Nat) : Bool {
|
|
107
|
-
Prim.btstNat64(x, Prim.natToNat64(p));
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
/// Returns the value of setting bit `p mod 64` in `x` to `1`.
|
|
111
|
-
public func bitset(x : Nat64, p : Nat) : Nat64 {
|
|
112
|
-
x | (1 << Prim.natToNat64(p));
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
/// Returns the value of clearing bit `p mod 64` in `x` to `0`.
|
|
116
|
-
public func bitclear(x : Nat64, p : Nat) : Nat64 {
|
|
117
|
-
x & ^(1 << Prim.natToNat64(p));
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/// Returns the value of flipping bit `p mod 64` in `x`.
|
|
121
|
-
public func bitflip(x : Nat64, p : Nat) : Nat64 {
|
|
122
|
-
x ^ (1 << Prim.natToNat64(p));
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/// Returns the count of non-zero bits in `x`.
|
|
126
|
-
public let bitcountNonZero : (x : Nat64) -> Nat64 = Prim.popcntNat64;
|
|
127
|
-
|
|
128
|
-
/// Returns the count of leading zero bits in `x`.
|
|
129
|
-
public let bitcountLeadingZero : (x : Nat64) -> Nat64 = Prim.clzNat64;
|
|
130
|
-
|
|
131
|
-
/// Returns the count of trailing zero bits in `x`.
|
|
132
|
-
public let bitcountTrailingZero : (x : Nat64) -> Nat64 = Prim.ctzNat64;
|
|
133
|
-
|
|
134
|
-
/// Returns the sum of `x` and `y`, `x +% y`. Wraps on overflow.
|
|
135
|
-
public func addWrap(x : Nat64, y : Nat64) : Nat64 { x +% y };
|
|
136
|
-
|
|
137
|
-
/// Returns the difference of `x` and `y`, `x -% y`. Wraps on underflow.
|
|
138
|
-
public func subWrap(x : Nat64, y : Nat64) : Nat64 { x -% y };
|
|
139
|
-
|
|
140
|
-
/// Returns the product of `x` and `y`, `x *% y`. Wraps on overflow.
|
|
141
|
-
public func mulWrap(x : Nat64, y : Nat64) : Nat64 { x *% y };
|
|
142
|
-
|
|
143
|
-
/// Returns `x` to the power of `y`, `x **% y`. Wraps on overflow.
|
|
144
|
-
public func powWrap(x : Nat64, y : Nat64) : Nat64 { x **% y };
|
|
145
|
-
|
|
146
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/// 8-bit unsigned integers with checked arithmetic
|
|
2
|
-
///
|
|
3
|
-
/// Most operations are available as built-in operators (e.g. `1 + 1`).
|
|
4
|
-
import Nat "Nat";
|
|
5
|
-
import Prim "mo:⛔";
|
|
6
|
-
|
|
7
|
-
module {
|
|
8
|
-
|
|
9
|
-
/// 8-bit natural numbers.
|
|
10
|
-
public type Nat8 = Prim.Types.Nat8;
|
|
11
|
-
|
|
12
|
-
/// Conversion.
|
|
13
|
-
public let toNat : Nat8 -> Nat = Prim.nat8ToNat;
|
|
14
|
-
|
|
15
|
-
/// Conversion. Traps on overflow/underflow.
|
|
16
|
-
public let fromNat : Nat -> Nat8 = Prim.natToNat8;
|
|
17
|
-
|
|
18
|
-
/// Conversion. Wraps on overflow/underflow.
|
|
19
|
-
public let fromIntWrap : Int -> Nat8 = Prim.intToNat8Wrap;
|
|
20
|
-
|
|
21
|
-
/// Returns the Text representation of `x`.
|
|
22
|
-
public func toText(x : Nat8) : Text {
|
|
23
|
-
Nat.toText(toNat(x))
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/// Returns the minimum of `x` and `y`.
|
|
27
|
-
public func min(x : Nat8, y : Nat8) : Nat8 {
|
|
28
|
-
if (x < y) { x } else { y }
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/// Returns the maximum of `x` and `y`.
|
|
32
|
-
public func max( x : Nat8, y : Nat8) : Nat8 {
|
|
33
|
-
if (x < y) { y } else { x }
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/// Returns `x == y`.
|
|
37
|
-
public func equal(x : Nat8, y : Nat8) : Bool { x == y };
|
|
38
|
-
|
|
39
|
-
/// Returns `x != y`.
|
|
40
|
-
public func notEqual(x : Nat8, y : Nat8) : Bool { x != y };
|
|
41
|
-
|
|
42
|
-
/// Returns `x < y`.
|
|
43
|
-
public func less(x : Nat8, y : Nat8) : Bool { x < y };
|
|
44
|
-
|
|
45
|
-
/// Returns `x <= y`.
|
|
46
|
-
public func lessOrEqual(x : Nat8, y : Nat8) : Bool { x <= y };
|
|
47
|
-
|
|
48
|
-
/// Returns `x > y`.
|
|
49
|
-
public func greater(x : Nat8, y : Nat8) : Bool { x > y };
|
|
50
|
-
|
|
51
|
-
/// Returns `x >= y`.
|
|
52
|
-
public func greaterOrEqual(x : Nat8, y : Nat8) : Bool { x >= y };
|
|
53
|
-
|
|
54
|
-
/// Returns the order of `x` and `y`.
|
|
55
|
-
public func compare(x : Nat8, y : Nat8) : { #less; #equal; #greater } {
|
|
56
|
-
if (x < y) { #less }
|
|
57
|
-
else if (x == y) { #equal }
|
|
58
|
-
else { #greater }
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/// Returns the sum of `x` and `y`, `x + y`. Traps on overflow.
|
|
62
|
-
public func add(x : Nat8, y : Nat8) : Nat8 { x + y };
|
|
63
|
-
|
|
64
|
-
/// Returns the difference of `x` and `y`, `x - y`. Traps on underflow.
|
|
65
|
-
public func sub(x : Nat8, y : Nat8) : Nat8 { x - y };
|
|
66
|
-
|
|
67
|
-
/// Returns the product of `x` and `y`, `x * y`. Traps on overflow.
|
|
68
|
-
public func mul(x : Nat8, y : Nat8) : Nat8 { x * y };
|
|
69
|
-
|
|
70
|
-
/// Returns the division of `x by y`, `x / y`.
|
|
71
|
-
/// Traps when `y` is zero.
|
|
72
|
-
public func div(x : Nat8, y : Nat8) : Nat8 { x / y };
|
|
73
|
-
|
|
74
|
-
/// Returns the remainder of `x` divided by `y`, `x % y`.
|
|
75
|
-
/// Traps when `y` is zero.
|
|
76
|
-
public func rem(x : Nat8, y : Nat8) : Nat8 { x % y };
|
|
77
|
-
|
|
78
|
-
/// Returns `x` to the power of `y`, `x ** y`. Traps on overflow.
|
|
79
|
-
public func pow(x : Nat8, y : Nat8) : Nat8 { x ** y };
|
|
80
|
-
|
|
81
|
-
/// Returns the bitwise negation of `x`, `^x`.
|
|
82
|
-
public func bitnot(x : Nat8, y : Nat8) : Nat8 { ^x };
|
|
83
|
-
|
|
84
|
-
/// Returns the bitwise and of `x` and `y`, `x & y`.
|
|
85
|
-
public func bitand(x : Nat8, y : Nat8) : Nat8 { x & y };
|
|
86
|
-
|
|
87
|
-
/// Returns the bitwise or of `x` and `y`, `x \| y`.
|
|
88
|
-
public func bitor(x : Nat8, y : Nat8) : Nat8 { x | y };
|
|
89
|
-
|
|
90
|
-
/// Returns the bitwise exclusive or of `x` and `y`, `x ^ y`.
|
|
91
|
-
public func bitxor(x : Nat8, y : Nat8) : Nat8 { x ^ y };
|
|
92
|
-
|
|
93
|
-
/// Returns the bitwise shift left of `x` by `y`, `x << y`.
|
|
94
|
-
public func bitshiftLeft(x : Nat8, y : Nat8) : Nat8 { x << y };
|
|
95
|
-
|
|
96
|
-
/// Returns the bitwise shift right of `x` by `y`, `x >> y`.
|
|
97
|
-
public func bitshiftRight(x : Nat8, y : Nat8) : Nat8 { x >> y };
|
|
98
|
-
|
|
99
|
-
/// Returns the bitwise rotate left of `x` by `y`, `x <<> y`.
|
|
100
|
-
public func bitrotLeft(x : Nat8, y : Nat8) : Nat8 { x <<> y };
|
|
101
|
-
|
|
102
|
-
/// Returns the bitwise rotate right of `x` by `y`, `x <>> y`.
|
|
103
|
-
public func bitrotRight(x : Nat8, y : Nat8) : Nat8 { x <>> y };
|
|
104
|
-
|
|
105
|
-
/// Returns the value of bit `p mod 8` in `x`, `(x & 2^(p mod 8)) == 2^(p mod 8)`.
|
|
106
|
-
public func bittest(x : Nat8, p : Nat) : Bool {
|
|
107
|
-
Prim.btstNat8(x, Prim.natToNat8(p));
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
/// Returns the value of setting bit `p mod 8` in `x` to `1`.
|
|
111
|
-
public func bitset(x : Nat8, p : Nat) : Nat8 {
|
|
112
|
-
x | (1 << Prim.natToNat8(p));
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
/// Returns the value of clearing bit `p mod 8` in `x` to `0`.
|
|
116
|
-
public func bitclear(x : Nat8, p : Nat) : Nat8 {
|
|
117
|
-
x & ^(1 << Prim.natToNat8(p));
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/// Returns the value of flipping bit `p mod 8` in `x`.
|
|
121
|
-
public func bitflip(x : Nat8, p : Nat) : Nat8 {
|
|
122
|
-
x ^ (1 << Prim.natToNat8(p));
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/// Returns the count of non-zero bits in `x`.
|
|
126
|
-
public let bitcountNonZero : (x : Nat8) -> Nat8 = Prim.popcntNat8;
|
|
127
|
-
|
|
128
|
-
/// Returns the count of leading zero bits in `x`.
|
|
129
|
-
public let bitcountLeadingZero : (x : Nat8) -> Nat8 = Prim.clzNat8;
|
|
130
|
-
|
|
131
|
-
/// Returns the count of trailing zero bits in `x`.
|
|
132
|
-
public let bitcountTrailingZero : (x : Nat8) -> Nat8 = Prim.ctzNat8;
|
|
133
|
-
|
|
134
|
-
/// Returns the sum of `x` and `y`, `x +% y`. Wraps on overflow.
|
|
135
|
-
public func addWrap(x : Nat8, y : Nat8) : Nat8 { x +% y };
|
|
136
|
-
|
|
137
|
-
/// Returns the difference of `x` and `y`, `x -% y`. Wraps on underflow.
|
|
138
|
-
public func subWrap(x : Nat8, y : Nat8) : Nat8 { x -% y };
|
|
139
|
-
|
|
140
|
-
/// Returns the product of `x` and `y`, `x *% y`. Wraps on overflow.
|
|
141
|
-
public func mulWrap(x : Nat8, y : Nat8) : Nat8 { x *% y };
|
|
142
|
-
|
|
143
|
-
/// Returns `x` to the power of `y`, `x **% y`. Wraps on overflow.
|
|
144
|
-
public func powWrap(x : Nat8, y : Nat8) : Nat8 { x **% y };
|
|
145
|
-
|
|
146
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/// The absent value
|
|
2
|
-
///
|
|
3
|
-
/// The `None` type represents a type with _no_ value.
|
|
4
|
-
///
|
|
5
|
-
/// It is often used to type code that fails to return control (e.g. an infinite loop)
|
|
6
|
-
/// or to designate impossible values (e.g. the type `?None` only contains `null`).
|
|
7
|
-
|
|
8
|
-
import Prim "mo:⛔";
|
|
9
|
-
|
|
10
|
-
module {
|
|
11
|
-
|
|
12
|
-
/// The empty type. A subtype of all types.
|
|
13
|
-
public type None = Prim.Types.None;
|
|
14
|
-
|
|
15
|
-
/// Turns an absurd value into an arbitrary type.
|
|
16
|
-
public let impossible : <A> None -> A = func<A>(x : None) : A {
|
|
17
|
-
switch (x) {};
|
|
18
|
-
};
|
|
19
|
-
}
|