diff --git a/src/Array.mo b/src/Array.mo index 5d6072b0..bb8e861c 100644 --- a/src/Array.mo +++ b/src/Array.mo @@ -397,6 +397,7 @@ module { /// Space: O(size) /// /// *Runtime and space assumes that `f` runs in O(1) time and space. + /// @deprecated M0235 public func mapResult(self : [T], f : T -> Types.Result) : Types.Result<[R], E> { let size = self.size(); diff --git a/src/Float.mo b/src/Float.mo index 911dde04..395927c1 100644 --- a/src/Float.mo +++ b/src/Float.mo @@ -462,6 +462,7 @@ module { /// ```motoko include=import /// assert Float.fromInt(-123) == -123.0; /// ``` + /// @deprecated M0235 public func fromInt(x : Int) : Float = Prim.intToFloat(x); /// Determines whether `x` is equal to `y` within the defined tolerance of `epsilon`. diff --git a/src/List.mo b/src/List.mo index 43ac20c1..3d6dcd5f 100644 --- a/src/List.mo +++ b/src/List.mo @@ -118,6 +118,7 @@ module { /// Runtime: `O(size)` /// /// Space: `O(size)` + /// @deprecated M0235 public func toPure(self : List) : PureList.List { var result : PureList.List = null; @@ -158,6 +159,7 @@ module { /// Runtime: `O(size)` /// /// Space: `O(size)` + /// @deprecated M0235 public func fromPure(pure : PureList.List) : List { var p = pure; var list = empty(); @@ -978,6 +980,7 @@ module { /// Runtime: `O(1)` /// /// Space: `O(1)` + /// @deprecated M0235 public func get(self : List, index : Nat) : ?T { // inlined version of locate let (a, b) = do { diff --git a/src/Map.mo b/src/Map.mo index 5ec844ca..6e101755 100644 --- a/src/Map.mo +++ b/src/Map.mo @@ -76,6 +76,7 @@ module { /// assuming that the `compare` function implements an `O(1)` comparison. /// /// Note: Creates `O(n * log(n))` temporary objects that will be collected as garbage. + /// @deprecated M0235 public func toPure(self : Map, compare : (implicit : (K, K) -> Order.Order)) : PureMap.Map { PureMap.fromIter(entries(self), compare) }; @@ -101,6 +102,7 @@ module { /// Space: `O(n)`. /// where `n` denotes the number of key-value entries stored in the map and /// assuming that the `compare` function implements an `O(1)` comparison. + /// @deprecated M0235 public func fromPure(map : PureMap.Map, compare : (implicit : (K, K) -> Order.Order)) : Map { fromIter(PureMap.entries(map), compare) }; @@ -385,6 +387,7 @@ module { /// Space: `O(log(n))`. /// where `n` denotes the number of key-value entries stored in the map and /// assuming that the `compare` function implements an `O(1)` comparison. + /// @deprecated M0235 public func insert(self : Map, compare : (implicit : (K, K) -> Order.Order), key : K, value : V) : Bool { switch (swap(self, compare, key, value)) { case null true; @@ -445,6 +448,7 @@ module { /// Space: `O(log(n))`. /// where `n` denotes the number of key-value entries stored in the map and /// assuming that the `compare` function implements an `O(1)` comparison. + /// @deprecated M0235 public func swap(self : Map, compare : (implicit : (K, K) -> Order.Order), key : K, value : V) : ?V { let insertResult = switch (self.root) { case (#leaf(leafNode)) { @@ -510,6 +514,7 @@ module { /// Space: `O(log(n))`. /// where `n` denotes the number of key-value entries stored in the map and /// assuming that the `compare` function implements an `O(1)` comparison. + /// @deprecated M0235 public func replace(self : Map, compare : (implicit : (K, K) -> Order.Order), key : K, value : V) : ?V { // TODO: Could be optimized in future if (containsKey(self, compare, key)) { @@ -576,6 +581,7 @@ module { /// assuming that the `compare` function implements an `O(1)` comparison. /// /// Note: Creates `O(log(n))` objects that will be collected as garbage. + /// @deprecated M0235 public func delete(self : Map, compare : (implicit : (K, K) -> Order.Order), key : K) : Bool { switch (take(self, compare, key)) { case null false; @@ -610,6 +616,7 @@ module { /// assuming that the `compare` function implements an `O(1)` comparison. /// /// Note: Creates `O(log(n))` objects that will be collected as garbage. + /// @deprecated M0235 public func take(self : Map, compare : (implicit : (K, K) -> Order.Order), key : K) : ?V { let deletedValue = switch (self.root) { case (#leaf(leafNode)) { @@ -1252,6 +1259,7 @@ module { /// Internal sanity check function. /// Can be used to check that key/value pairs have been inserted with a consistent key comparison function. /// Traps if the internal map structure is invalid. + /// @deprecated M0235 public func assertValid(self : Map, compare : (implicit : (K, K) -> Order.Order)) { func checkIteration(iterator : Types.Iter<(K, V)>, order : Order.Order) { switch (iterator.next()) { diff --git a/src/Nat.mo b/src/Nat.mo index b010cee1..1cb94ebd 100644 --- a/src/Nat.mo +++ b/src/Nat.mo @@ -75,6 +75,7 @@ module { /// ```motoko include=import /// assert Nat.fromInt(1234) == (1234 : Nat); /// ``` + /// @deprecated M0235 public func fromInt(int : Int) : Nat { if (int < 0) { Runtime.trap("Nat.fromInt(): negative input value") diff --git a/src/Nat16.mo b/src/Nat16.mo index 592a6909..23f76169 100644 --- a/src/Nat16.mo +++ b/src/Nat16.mo @@ -48,6 +48,7 @@ module { /// ```motoko include=import /// assert Nat16.fromNat8(123) == (123 : Nat16); /// ``` + /// @deprecated M0235 public func fromNat8(x : Nat8) : Nat16 { Prim.nat8ToNat16(x) }; @@ -72,6 +73,7 @@ module { /// ```motoko include=import /// assert Nat16.fromNat32(123) == (123 : Nat16); /// ``` + /// @deprecated M0235 public func fromNat32(x : Nat32) : Nat16 { Prim.nat32ToNat16(x) }; diff --git a/src/Nat32.mo b/src/Nat32.mo index e9e4ade8..2e7716eb 100644 --- a/src/Nat32.mo +++ b/src/Nat32.mo @@ -48,6 +48,7 @@ module { /// ```motoko include=import /// assert Nat32.fromNat16(123) == (123 : Nat32); /// ``` + /// @deprecated M0235 public func fromNat16(x : Nat16) : Nat32 { Prim.nat16ToNat32(x) }; @@ -72,6 +73,7 @@ module { /// ```motoko include=import /// assert Nat32.fromNat64(123) == (123 : Nat32); /// ``` + /// @deprecated M0235 public func fromNat64(x : Nat64) : Nat32 { Prim.nat64ToNat32(x) }; diff --git a/src/Nat64.mo b/src/Nat64.mo index 040efdc8..41b0f770 100644 --- a/src/Nat64.mo +++ b/src/Nat64.mo @@ -48,6 +48,7 @@ module { /// ```motoko include=import /// assert Nat64.fromNat32(123) == (123 : Nat64); /// ``` + /// @deprecated M0235 public func fromNat32(x : Nat32) : Nat64 { Prim.nat32ToNat64(x) }; diff --git a/src/Queue.mo b/src/Queue.mo index 6b19796b..d8f48c57 100644 --- a/src/Queue.mo +++ b/src/Queue.mo @@ -56,6 +56,7 @@ module { /// Runtime: O(n) /// Space: O(n) /// `n` denotes the number of elements stored in the queue. + /// @deprecated M0235 public func toPure(self : Queue) : PureQueue.Queue { let pureQueue = PureQueue.empty(); let iter = values(self); @@ -84,6 +85,7 @@ module { /// Runtime: O(n) /// Space: O(n) /// `n` denotes the number of elements stored in the queue. + /// @deprecated M0235 public func fromPure(pureQueue : PureQueue.Queue) : Queue { let queue = empty(); let iter = PureQueue.values(pureQueue); diff --git a/src/Random.mo b/src/Random.mo index 2ea7d962..00f8eef0 100644 --- a/src/Random.mo +++ b/src/Random.mo @@ -30,6 +30,7 @@ module { let rawRand = (actor "aaaaa-aa" : actor { raw_rand : () -> async Blob }).raw_rand; + /// @deprecated M0235 public let blob : shared () -> async Blob = rawRand; /// Initializes a random number generator state. This is used @@ -49,6 +50,7 @@ module { /// } /// } /// ``` + /// @deprecated M0235 public func emptyState() : State = { var bytes = []; var index = 0; @@ -73,6 +75,7 @@ module { /// } /// } /// ``` + /// @deprecated M0235 public func seedState(seed : Nat64) : SeedState = { random = emptyState(); prng = PRNG.init(seed) @@ -87,6 +90,7 @@ module { /// let random = Random.seed(123); /// let coin = random.bool(); // true or false /// ``` + /// @deprecated M0235 public func seed(seed : Nat64) : Random { seedFromState(seedState(seed)) }; @@ -108,6 +112,7 @@ module { /// } /// } /// ``` + /// @deprecated M0235 public func seedFromState(state : SeedState) : Random { Random( state.random, @@ -191,6 +196,7 @@ module { /// let random = Random.seed(42); /// let coin = random.bool(); // true or false /// ``` + /// @deprecated M0235 public func bool() : Bool { nextBit() }; @@ -202,6 +208,7 @@ module { /// let random = Random.seed(42); /// let byte = random.nat8(); // 0 to 255 /// ``` + /// @deprecated M0235 public func nat8() : Nat8 { if (state.index >= state.bytes.size()) { let newBytes = Blob.toArray(generator()); @@ -257,6 +264,7 @@ module { /// let random = Random.seed(42); /// let number = random.nat64(); // 0 to 18446744073709551615 /// ``` + /// @deprecated M0235 public func nat64() : Nat64 { (Nat64.fromNat(Nat8.toNat(nat8())) << 56) | (Nat64.fromNat(Nat8.toNat(nat8())) << 48) | (Nat64.fromNat(Nat8.toNat(nat8())) << 40) | (Nat64.fromNat(Nat8.toNat(nat8())) << 32) | (Nat64.fromNat(Nat8.toNat(nat8())) << 24) | (Nat64.fromNat(Nat8.toNat(nat8())) << 16) | (Nat64.fromNat(Nat8.toNat(nat8())) << 8) | Nat64.fromNat(Nat8.toNat(nat8())) }; @@ -268,6 +276,7 @@ module { /// let random = Random.seed(42); /// let dice = random.nat64Range(1, 7); // 1 to 6 /// ``` + /// @deprecated M0235 public func nat64Range(fromInclusive : Nat64, toExclusive : Nat64) : Nat64 { if (fromInclusive >= toExclusive) { Runtime.trap("Random.nat64Range(): fromInclusive >= toExclusive") @@ -282,6 +291,7 @@ module { /// let random = Random.seed(42); /// let index = random.natRange(0, 10); // 0 to 9 /// ``` + /// @deprecated M0235 public func natRange(fromInclusive : Nat, toExclusive : Nat) : Nat { if (fromInclusive >= toExclusive) { Runtime.trap("Random.natRange(): fromInclusive >= toExclusive") @@ -289,6 +299,7 @@ module { Nat64.toNat(uniform64(Nat64.fromNat(toExclusive - fromInclusive - 1))) + fromInclusive }; + /// @deprecated M0235 public func intRange(fromInclusive : Int, toExclusive : Int) : Int { let range = Nat.fromInt(toExclusive - fromInclusive - 1); Nat64.toNat(uniform64(Nat64.fromNat(range))) + fromInclusive diff --git a/src/Region.mo b/src/Region.mo index f6bc4122..4adb0a91 100644 --- a/src/Region.mo +++ b/src/Region.mo @@ -55,6 +55,7 @@ module { /// A stateful handle to an isolated region of IC stable memory. /// `Region` is a stable type and regions can be stored in stable variables. + /// @deprecated M0235 public type Region = Prim.Types.Region; /// Allocate a new, isolated Region of size 0. diff --git a/src/Result.mo b/src/Result.mo index 327e1f29..08aa4784 100644 --- a/src/Result.mo +++ b/src/Result.mo @@ -43,6 +43,7 @@ module { /// assert validateEmail("@domain.com") == #err("Username cannot be empty"); /// assert validateEmail("user@invalid") == #err("Invalid domain format"); /// ``` + /// @deprecated M0235 public type Result = Types.Result; /// Compares two Results for equality. diff --git a/src/Set.mo b/src/Set.mo index 46105f27..20ad4f59 100644 --- a/src/Set.mo +++ b/src/Set.mo @@ -71,6 +71,7 @@ module { /// assuming that the `compare` function implements an `O(1)` comparison. /// /// Note: Creates `O(n * log(n))` temporary objects that will be collected as garbage. + /// @deprecated M0235 public func toPure(self : Set, compare : (implicit : (T, T) -> Order.Order)) : PureSet.Set { PureSet.fromIter(values(self), compare) }; @@ -95,6 +96,7 @@ module { /// Space: `O(n)`. /// where `n` denotes the number of elements stored in the set and /// assuming that the `compare` function implements an `O(1)` comparison. + /// @deprecated M0235 public func fromPure(set : PureSet.Set, compare : (implicit : (T, T) -> Order.Order)) : Set { fromIter(PureSet.values(set), compare) }; @@ -375,6 +377,7 @@ module { /// Space: `O(log(n))`. /// where `n` denotes the number of elements stored in the set and /// assuming that the `compare` function implements an `O(1)` comparison. + /// @deprecated M0235 public func insert(self : Set, compare : (implicit : (T, T) -> Order.Order), element : T) : Bool { let insertResult = switch (self.root) { case (#leaf(leafNode)) { @@ -469,6 +472,7 @@ module { /// assuming that the `compare` function implements an `O(1)` comparison. /// /// Note: Creates `O(log(n))` objects that will be collected as garbage. + /// @deprecated M0235 public func delete(self : Set, compare : (implicit : (T, T) -> Order.Order), element : T) : Bool { let deleted = switch (self.root) { case (#leaf(leafNode)) { @@ -923,6 +927,7 @@ module { /// Space: `O(1)` retained memory plus garbage, see the note below. /// where `m` and `n` denote the number of elements in `set` and `iter`, respectively, /// and assuming that the `compare` function implements an `O(1)` comparison. + /// @deprecated M0235 public func deleteAll(self : Set, compare : (implicit : (T, T) -> Order.Order), iter : Types.Iter) : Bool { var deleted = false; for (element in iter) { @@ -953,6 +958,7 @@ module { /// Space: `O(1)` retained memory plus garbage, see the note below. /// where `m` and `n` denote the number of elements in `set` and `iter`, respectively, /// and assuming that the `compare` function implements an `O(1)` comparison. + /// @deprecated M0235 public func insertAll(self : Set, compare : (implicit : (T, T) -> Order.Order), iter : Types.Iter) : Bool { var inserted = false; for (element in iter) { @@ -1356,6 +1362,7 @@ module { /// Internal sanity check function. /// Can be used to check that elements have been inserted with a consistent comparison function. /// Traps if the internal set structure is invalid. + /// @deprecated M0235 public func assertValid(self : Set, compare : (implicit : (T, T) -> Order.Order)) { func checkIteration(iterator : Types.Iter, order : Order.Order) { switch (iterator.next()) { diff --git a/src/Stack.mo b/src/Stack.mo index e00a712e..fd451d06 100644 --- a/src/Stack.mo +++ b/src/Stack.mo @@ -59,6 +59,7 @@ module { /// Runtime: `O(1)`. /// Space: `O(1)`. /// where `n` denotes the number of elements stored in the stack. + /// @deprecated M0235 public func toPure(self : Stack) : PureList.List { self.top }; @@ -90,6 +91,7 @@ module { /// Runtime: `O(n)`. /// Space: `O(n)`. /// where `n` denotes the number of elements stored in the queue. + /// @deprecated M0235 public func fromPure(list : PureList.List) : Stack { var size = 0; var cur = list; diff --git a/src/VarArray.mo b/src/VarArray.mo index 3c1a4e1f..bad075fa 100644 --- a/src/VarArray.mo +++ b/src/VarArray.mo @@ -528,6 +528,7 @@ module { /// Space: O(size) /// /// *Runtime and space assumes that `f` runs in O(1) time and space. + /// @deprecated M0235 public func mapResult(self : [var T], f : T -> Result.Result) : Result.Result<[var R], E> { let size = self.size(); diff --git a/src/WeakReference.mo b/src/WeakReference.mo index d5839216..d201f31a 100644 --- a/src/WeakReference.mo +++ b/src/WeakReference.mo @@ -11,6 +11,7 @@ import Prim "mo:⛔" module { + //TODO: @deprecated M0235 public type WeakReference = { ref : weak T }; diff --git a/src/pure/List.mo b/src/pure/List.mo index a03808a3..c0d36f1e 100644 --- a/src/pure/List.mo +++ b/src/pure/List.mo @@ -20,6 +20,7 @@ import Runtime "../Runtime"; module { + /// @deprecated M0235 public type List = Types.Pure.List; /// Create an empty list. diff --git a/src/pure/Map.mo b/src/pure/Map.mo index fa7c7d83..ebddab37 100644 --- a/src/pure/Map.mo +++ b/src/pure/Map.mo @@ -60,6 +60,7 @@ import Runtime "../Runtime"; module { + /// @deprecated M0235 public type Map = Types.Pure.Map; type Tree = Types.Pure.Map.Tree; diff --git a/src/pure/Queue.mo b/src/pure/Queue.mo index ba50f98e..e7cbab24 100644 --- a/src/pure/Queue.mo +++ b/src/pure/Queue.mo @@ -36,6 +36,7 @@ import Array "../Array"; import Prim "mo:⛔"; module { + /// @deprecated M0235 type List = Types.Pure.List; /// Double-ended queue data type. diff --git a/src/pure/Set.mo b/src/pure/Set.mo index 9a0201ee..020c79a5 100644 --- a/src/pure/Set.mo +++ b/src/pure/Set.mo @@ -46,6 +46,8 @@ module { /// If type `T` is stable then `Set` is also stable. /// To ensure that property the `Set` does not have any methods, /// instead they are gathered in the functor-like class `Operations` (see example there). + + /// @deprecated M0235 public type Set = Types.Pure.Set; /// Red-black tree of nodes with ordered set elements.