Skip to content

Commit

Permalink
Merge pull request #1164 from tweag/task/long-type-names
Browse files Browse the repository at this point in the history
Long names for `Str`, `Num`, related functions and modules
  • Loading branch information
yannham authored Mar 9, 2023
2 parents e664828 + dcbbfed commit 5c665e4
Show file tree
Hide file tree
Showing 88 changed files with 965 additions and 929 deletions.
4 changes: 2 additions & 2 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ with a comment declaring the expected behaviour. For example
# test: blame
let Even = fun label value =>
if builtin.is_num value && value % 2 == 0 then
if builtin.is_number value && value % 2 == 0 then
value
else
contract.blame label in
let DivBy3 = fun label value =>
if builtin.is_num value && value % 3 == 0 then
if builtin.is_number value && value % 3 == 0 then
value
else
contract.blame label in
Expand Down
18 changes: 18 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
Version 1.0 (?)
===============

This is WIP, registering breaking changes for the next major version.

Breaking changes
----------------

- The `Num` builtin type has been renamed to `Number`
- The `Str` builtin type has been renamed to `String`
- The `num` stdlib module has been remaned to `number`
- The `builtin.typeof` function now returns `` `Number ``, `` `String ``,
`` `Function `` instead of respectively `` `Num ``, `` `Str ``, and `` `Fun ``
- The `builtin.is_num`, `builtin.is_str` and `builtin.to_str` functions hav been
renamed to `is_number`, `is_string` and `to_string`
- The `string.to_num` and `string.from_num` functions have been renamed to
`to_number` and `from_number`

Version 0.3.1 (2022-12-15)
==========================

Expand Down
2 changes: 1 addition & 1 deletion benches/arrays/fold.ncl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let letter | Num -> string.CharLiteral = fun n =>
let letter | Number -> string.CharLiteral = fun n =>
string.code "a" + (n % 26)
|> string.from_code in

Expand Down
2 changes: 1 addition & 1 deletion benches/arrays/generate.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let g = fun n => n*2 + 5 in
run = fun n => generate n g,
},
checked = {
generate_with_contract | forall a. Num -> (Num -> a) -> Array a = fun n g =>
generate_with_contract | forall a. Number -> (Number -> a) -> Array a = fun n g =>
if n == 0 then []
else generate_with_contract (n - 1) g @ [g n],

Expand Down
6 changes: 3 additions & 3 deletions benches/arrays/primes.ncl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let range
| doc "Generate an array of integers in the range [`start`, `end`)."
| Num -> Num -> Array Num
| Number -> Number -> Array Number
= fun start end =>
if end <= start then
[]
Expand All @@ -17,9 +17,9 @@ let Prime = contract.from_predicate is_prime in

let primes
| doc "Generate `max` primes using Sieve of Eratosthenes."
| Num -> Array Prime
| Number -> Array Prime
= fun max =>
let limit = num.pow max (1 / 2) in # sqrt(max)
let limit = number.pow max (1 / 2) in # sqrt(max)
let drop_multiples = fun x xs =>
let to_drop = max
|> array.generate (fun y => (y + 2) * x)
Expand Down
4 changes: 2 additions & 2 deletions benches/arrays/random.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ let mgc
# of the 2021 paper "Computationally Easy, Spectrally Good Multipliers for
# Congruential Pseudorandom Number Generators", by Guy Steele and Sebastiano Vigna.
# But, they cannot be used because they require bit-shifting to select the 32 MSBs.
# let params = { m = num.pow 2 32, a = 2480367069 } in
# let params = { m = number.pow 2 32, a = 2480367069 } in

# These parameters are from the "Numerical Recipes" book.
let params = { m = num.pow 2 32, a = 1664525, c = 1013904223 } in
let params = { m = number.pow 2 32, a = 1664525, c = 1013904223 } in

let rec array_random = fun init n =>
if n == 0 then [init]
Expand Down
2 changes: 1 addition & 1 deletion benches/arrays/sum.ncl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let rec sum
| Array Num -> Num
| Array Number -> Number
= fun xs =>
if array.length xs == 0 then 0
else array.first xs + sum (array.drop_first xs)
Expand Down
2 changes: 1 addition & 1 deletion benches/mantis/deploy.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fun vars =>
"eu-west-2"])
| default = ["eu-central-1", "us-east-2"],
fqdn = "mantis.ws",
networkConfig | Str
networkConfig | String
| default = m%"
mantis.blockchains.testnet-internal-nomad.bootstrap-nodes = [
%{string.join ",\n" bootstrapNodes."%{vars.namespace}"})
Expand Down
18 changes: 9 additions & 9 deletions benches/mantis/jobs/mantis.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ let lib = import "../lib.ncl" in
let baseTags = [""] in

let Params = {
count | num.Nat
count | number.Nat
| default = 5,
role | [| `passive, `miner, `backup |],
datacenters | Dyn,
job | Dyn,
namespace | Str,
logLevel | Str,
mantisRev | Str,
fqdn | Str,
loggers | {_: Str},
namespace | String,
logLevel | String,
mantisRev | String,
fqdn | String,
loggers | {_: String},
network | lib.contracts.OneOf ["testnet-internal-nomad", "etc"]
| default = "testnet-internal-nomad",
networkConfig | Str,
networkConfig | String,

fastSync | Bool
| default = false,
reschedule | {..}
#{_ : lib.contracts.PseudoOr [
# lib.contracts.OrableFromPred builtin.is_str,
# lib.contracts.OrableFromPred builtin.is_num,
# lib.contracts.OrableFromPred builtin.is_string,
# lib.contracts.OrableFromPred builtin.is_number,
# lib.contracts.OrableFromPred builtin.is_bool,
# {
# pred = builtin.is_record,
Expand Down
2 changes: 1 addition & 1 deletion benches/mantis/lib.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
SmallerEq = fun x => contract.from_predicate (fun y => y <= x),
MatchRegexp = fun regex label value =>
let str_match = string.is_match regex in
if builtin.is_str value then
if builtin.is_string value then
if str_match value then
value
else
Expand Down
Loading

0 comments on commit 5c665e4

Please sign in to comment.