From 00f2382b3730281804352c7586f3cb1c5a499dbf Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Mon, 24 May 2021 14:54:48 +0100 Subject: [PATCH 1/2] add Prim.Types; update next-moc --- nix/sources.json | 6 +++--- src/prelude/prim.mo | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/nix/sources.json b/nix/sources.json index 10fc7b0a0b4..6e3fb1e40c5 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -50,10 +50,10 @@ "homepage": null, "owner": "dfinity", "repo": "motoko-base", - "rev": "712e857cb1a0d2149da8027fe746cfb8e346cc58", - "sha256": "0smvjx9i7a6jjbzgliw6n6f6gz3jvqv04ywcrjfvzxfida4h8cjc", + "rev": "1b0b25399fe5747bf63321950f386ed6263456fe", + "sha256": "1r1y61gaqpazm1h35mz0ds4yd8imqm39pdxmpiaj5mg3sgykxdlw", "type": "tarball", - "url": "https://github.com/dfinity/motoko-base/archive/712e857cb1a0d2149da8027fe746cfb8e346cc58.tar.gz", + "url": "https://github.com/dfinity/motoko-base/archive/1b0b25399fe5747bf63321950f386ed6263456fe.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "motoko-matchers": { diff --git a/src/prelude/prim.mo b/src/prelude/prim.mo index 2439035930e..e37f2ef8761 100644 --- a/src/prelude/prim.mo +++ b/src/prelude/prim.mo @@ -15,6 +15,29 @@ Nevertheless, it shoud be _safe_ to import prim, i.e. the definitions here should not break type safety or other guarantees of the language. */ +module Types = { + public type Any = prim "Any"; + public type None = prim "None"; + public type Null = prim "Null"; + public type Bool = prim "Bool"; + public type Nat = prim "Nat"; + public type Nat8 = prim "Nat8"; + public type Nat16 = prim "Nat16"; + public type Nat32 = prim "Nat32"; + public type Nat64 = prim "Nat64"; + public type Int = prim "Int"; + public type Int8 = prim "Int8"; + public type Int16 = prim "Int16"; + public type Int32 = prim "Int32"; + public type Int64 = prim "Int64"; + public type Float = prim "Float"; + public type Char = prim "Char"; + public type Text = prim "Text"; + public type Blob = prim "Blob"; + public type Error = prim "Error"; + public type Principal = prim "Principal"; +}; + func abs(x : Int) : Nat { (prim "abs" : Int -> Nat) x }; // for testing From 4cd3ef396eab10df79cb3bfefe78ad4fd1bf6d50 Mon Sep 17 00:00:00 2001 From: Claudio Russo Date: Mon, 24 May 2021 15:00:38 +0100 Subject: [PATCH 2/2] changelog++ --- Changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Changelog.md b/Changelog.md index 6ecf483716a..f785594a3e0 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,10 @@ # Motoko compiler changelog +* motoko-base: + + * reformat to style guidelines + * add type bindings `Nat.Nat`, `Nat8.Nat8` etc. to libraries for primitive types. + * Bugfix: generation of candid from Motoko: * no longer confused by distinct, but eponymous, type definitions (Bug: #2529);