Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Format sources and remove @uncurry #8

Merged
merged 2 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions js/src/js_array.res
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ let code = s => Js.String.charCodeAt(0, s)
Js.Array.fromMap(strArr, code) == [97.0, 98.0, 99.0, 100.0]
```
*/
external fromMap: (array_like<'a>, ('a => 'b)) => array<'b> = "Array.from"
external fromMap: (array_like<'a>, 'a => 'b) => array<'b> = "Array.from"

/* ES2015 */

Expand Down Expand Up @@ -689,7 +689,7 @@ Js.Array.every(isEven, [6, 22, 8, 4]) == true
Js.Array.every(isEven, [6, 22, 7, 4]) == false
```
*/
external every: (('a => bool)) => bool = "every"
external every: ('a => bool) => bool = "every"

@send.pipe(: t<'a> as 'this)
/**
Expand Down Expand Up @@ -718,7 +718,7 @@ let nonEmpty = s => s != ""
Js.Array.filter(nonEmpty, ["abc", "", "", "def", "ghi"]) == ["abc", "def", "ghi"]
```
*/
external filter: (('a => bool)) => 'this = "filter"
external filter: ('a => bool) => 'this = "filter"

@send.pipe(: t<'a> as 'this)
/**
Expand Down Expand Up @@ -756,7 +756,7 @@ Js.Array.find(x => x < 0, [33, 22, -55, 77, -44]) == Some(-55)
Js.Array.find(x => x < 0, [33, 22, 55, 77, 44]) == None
```
*/
external find: (('a => bool)) => option<'a> = "find"
external find: ('a => bool) => option<'a> = "find"

@send.pipe(: t<'a> as 'this)
@return(nullable)
Expand Down Expand Up @@ -786,7 +786,7 @@ Js.Array.findIndex(x => x < 0, [33, 22, -55, 77, -44]) == 2
Js.Array.findIndex(x => x < 0, [33, 22, 55, 77, 44]) == -1
```
*/
external findIndex: (('a => bool)) => int = "findIndex"
external findIndex: ('a => bool) => int = "findIndex"

@send.pipe(: t<'a> as 'this)
/**
Expand Down Expand Up @@ -815,7 +815,7 @@ The `forEach()` function applies the function given as the first argument to eac
Js.Array.forEach(x => Js.log(x), ["a", "b", "c"]) == ()
```
*/
external forEach: (('a => unit)) => unit = "forEach"
external forEach: ('a => unit) => unit = "forEach"

@send.pipe(: t<'a> as 'this)
/**
Expand Down Expand Up @@ -849,7 +849,7 @@ Js.Array.map(x => x * x, [12, 4, 8]) == [144, 16, 64]
Js.Array.map(Js.String.length, ["animal", "vegetable", "mineral"]) == [6, 9, 7]
```
*/
external map: (('a => 'b)) => t<'b> = "map"
external map: ('a => 'b) => t<'b> = "map"

@send.pipe(: t<'a> as 'this)
/**
Expand Down Expand Up @@ -1020,7 +1020,7 @@ Js.Array.some(isEven, [3, 7, 5, 2, 9]) == true
Js.Array.some(isEven, [3, 7, 5, 1, 9]) == false
```
*/
external some: (('a => bool)) => bool = "some"
external some: ('a => bool) => bool = "some"

@send.pipe(: t<'a> as 'this)
/**
Expand Down
40 changes: 20 additions & 20 deletions js/src/js_array2.res
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ let code = s => Js.String.charCodeAt(0, s)
Js.Array2.fromMap(strArr, code) == [97.0, 98.0, 99.0, 100.0]
```
*/
external fromMap: (array_like<'a>, @uncurry ('a => 'b)) => array<'b> = "Array.from"
external fromMap: (array_like<'a>, 'a => 'b) => array<'b> = "Array.from"

/* ES2015 */

Expand Down Expand Up @@ -399,7 +399,7 @@ let reverseNumeric = (n1, n2) => n2 - n1
Js.Array2.sortInPlaceWith(numbers, reverseNumeric) == [30, 20, 10, 3, 2, 1]
```
*/
external sortInPlaceWith: (t<'a>, @uncurry ('a, 'a) => int) => t<'a> = "sort"
external sortInPlaceWith: (t<'a>, ('a, 'a) => int) => t<'a> = "sort"

@send
@variadic
Expand Down Expand Up @@ -740,7 +740,7 @@ Js.Array2.every([6, 22, 8, 4], isEven) == true
Js.Array2.every([6, 22, 7, 4], isEven) == false
```
*/
external every: (t<'a>, @uncurry ('a => bool)) => bool = "every"
external every: (t<'a>, 'a => bool) => bool = "every"

@send
/**
Expand All @@ -762,7 +762,7 @@ Js.Array2.everyi([6, -3, 5, 8], evenIndexPositive) == true
Js.Array2.everyi([6, 3, -5, 8], evenIndexPositive) == false
```
*/
external everyi: (t<'a>, @uncurry ('a, int) => bool) => bool = "every"
external everyi: (t<'a>, ('a, int) => bool) => bool = "every"

@send
/**
Expand All @@ -779,7 +779,7 @@ let nonEmpty = s => s != ""
Js.Array2.filter(["abc", "", "", "def", "ghi"], nonEmpty) == ["abc", "def", "ghi"]
```
*/
external filter: (t<'a>, @uncurry ('a => bool)) => t<'a> = "filter"
external filter: (t<'a>, 'a => bool) => t<'a> = "filter"

@send
/**
Expand All @@ -800,7 +800,7 @@ let positiveOddElement = (item, index) => mod(index, 2) == 1 && item > 0
Js.Array2.filteri([6, 3, 5, 8, 7, -4, 1], positiveOddElement) == [3, 8]
```
*/
external filteri: (t<'a>, @uncurry ('a, int) => bool) => t<'a> = "filter"
external filteri: (t<'a>, ('a, int) => bool) => t<'a> = "filter"

@send
@return({undefined_to_opt: undefined_to_opt})
Expand All @@ -818,7 +818,7 @@ Js.Array2.find([33, 22, -55, 77, -44], x => x < 0) == Some(-55)
Js.Array2.find([33, 22, 55, 77, 44], x => x < 0) == None
```
*/
external find: (t<'a>, @uncurry ('a => bool)) => option<'a> = "find"
external find: (t<'a>, 'a => bool) => option<'a> = "find"

/* ES2015 */

Expand All @@ -841,7 +841,7 @@ Js.Array2.findi([66, -33, 55, 88, 22], positiveOddElement) == Some(88)
Js.Array2.findi([66, -33, 55, -88, 22], positiveOddElement) == None
```
*/
external findi: (t<'a>, @uncurry ('a, int) => bool) => option<'a> = "find"
external findi: (t<'a>, ('a, int) => bool) => option<'a> = "find"

/* ES2015 */

Expand All @@ -859,7 +859,7 @@ Js.Array2.findIndex([33, 22, -55, 77, -44], x => x < 0) == 2
Js.Array2.findIndex([33, 22, 55, 77, 44], x => x < 0) == -1
```
*/
external findIndex: (t<'a>, @uncurry ('a => bool)) => int = "findIndex"
external findIndex: (t<'a>, 'a => bool) => int = "findIndex"

/* ES2015 */

Expand All @@ -881,7 +881,7 @@ Js.Array2.findIndexi([66, -33, 55, 88, 22], positiveOddElement) == 3
Js.Array2.findIndexi([66, -33, 55, -88, 22], positiveOddElement) == -1
```
*/
external findIndexi: (t<'a>, @uncurry ('a, int) => bool) => int = "findIndex"
external findIndexi: (t<'a>, ('a, int) => bool) => int = "findIndex"

/* ES2015 */

Expand All @@ -902,7 +902,7 @@ on MDN.
Js.Array2.forEach(["a", "b", "c"], x => Js.log(x)) == ()
```
*/
external forEach: (t<'a>, @uncurry ('a => unit)) => unit = "forEach"
external forEach: (t<'a>, 'a => unit) => unit = "forEach"

@send
/**
Expand All @@ -922,7 +922,7 @@ on MDN.
Js.Array2.forEachi(["a", "b", "c"], (item, index) => Js.log2(index + 1, item)) == ()
```
*/
external forEachi: (t<'a>, @uncurry ('a, int) => unit) => unit = "forEach"
external forEachi: (t<'a>, ('a, int) => unit) => unit = "forEach"

/* commented out until bs has a plan for iterators
external keys : 'a t -> int array_iter = "" [@@send] (* ES2015 *)
Expand All @@ -943,7 +943,7 @@ Js.Array2.map([12, 4, 8], x => x * x) == [144, 16, 64]
Js.Array2.map(["animal", "vegetable", "mineral"], Js.String.length) == [6, 9, 7]
```
*/
external map: (t<'a>, @uncurry ('a => 'b)) => t<'b> = "map"
external map: (t<'a>, 'a => 'b) => t<'b> = "map"

@send
/**
Expand All @@ -962,7 +962,7 @@ let product = (item, index) => item * index
Js.Array2.mapi([10, 11, 12], product) == [0, 11, 24]
```
*/
external mapi: (t<'a>, @uncurry ('a, int) => 'b) => t<'b> = "map"
external mapi: (t<'a>, ('a, int) => 'b) => t<'b> = "map"

@send
/**
Expand Down Expand Up @@ -996,7 +996,7 @@ Js.Array2.reduce(
Js.Array2.reduce([2.0, 4.0], (acc, item) => item /. acc, 1.0) == 2.0 // 4.0 / (2.0 / 1.0)
```
*/
external reduce: (t<'a>, @uncurry ('b, 'a) => 'b, 'b) => 'b = "reduce"
external reduce: (t<'a>, ('b, 'a) => 'b, 'b) => 'b = "reduce"

@send
/**
Expand Down Expand Up @@ -1031,7 +1031,7 @@ let sumOfEvens = (accumulator, item, index) =>
Js.Array2.reducei([2, 5, 1, 4, 3], sumOfEvens, 0) == 6
```
*/
external reducei: (t<'a>, @uncurry ('b, 'a, int) => 'b, 'b) => 'b = "reduce"
external reducei: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b = "reduce"

@send
/**
Expand Down Expand Up @@ -1063,7 +1063,7 @@ Js.Array2.reduceRight([10, 2, 4], sumOfSquares, 0) == 120
Js.Array2.reduceRight([2.0, 4.0], (acc, item) => item /. acc, 1.0) == 0.5 // 2.0 / (4.0 / 1.0)
```
*/
external reduceRight: (t<'a>, @uncurry ('b, 'a) => 'b, 'b) => 'b = "reduceRight"
external reduceRight: (t<'a>, ('b, 'a) => 'b, 'b) => 'b = "reduceRight"

@send
/**
Expand Down Expand Up @@ -1100,7 +1100,7 @@ let sumOfEvens = (accumulator, item, index) =>
Js.Array2.reduceRighti([2, 5, 1, 4, 3], sumOfEvens, 0) == 6
```
*/
external reduceRighti: (t<'a>, @uncurry ('b, 'a, int) => 'b, 'b) => 'b = "reduceRight"
external reduceRighti: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b = "reduceRight"

@send
/**
Expand All @@ -1116,7 +1116,7 @@ Js.Array2.some([3, 7, 5, 2, 9], isEven) == true
Js.Array2.some([3, 7, 5, 1, 9], isEven) == false
```
*/
external some: (t<'a>, @uncurry ('a => bool)) => bool = "some"
external some: (t<'a>, 'a => bool) => bool = "some"

@send
/**
Expand All @@ -1139,7 +1139,7 @@ Js.Array2.somei(["ab", "cd", "ef", "gh"], sameLength) == true
Js.Array2.somei(["a", "bc", "def", "gh"], sameLength) == false
```
*/
external somei: (t<'a>, @uncurry ('a, int) => bool) => bool = "some"
external somei: (t<'a>, ('a, int) => bool) => bool = "some"

/* commented out until bs has a plan for iterators
external values : 'a t -> 'a array_iter = "" [@@send] (* ES2015 *)
Expand Down
4 changes: 2 additions & 2 deletions js/src/js_dict.res
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ external keys: t<'a> => array<key> = "Object.keys"
@obj
external empty: unit => t<'a> = ""

let unsafeDeleteKey: (. t<string>, string) => unit = %raw(` function (dict,key){
let unsafeDeleteKey: (t<string>, string) => unit = %raw(` function (dict,key){
delete dict[key];
}
`)
Expand Down Expand Up @@ -118,7 +118,7 @@ let map = (f, source) => {
let l = Js_array2.length(keys)
for i in 0 to l - 1 {
let key = Js_array2.unsafe_get(keys, i)
set(target, key, f(. unsafeGet(source, key)))
set(target, key, f(unsafeGet(source, key)))
}
target
}
4 changes: 2 additions & 2 deletions js/src/js_dict.resi
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ external keys: t<'a> => array<string> = "Object.keys"
external empty: unit => t<'a> = ""

/** Experimental internal function */
let unsafeDeleteKey: (. t<string>, string) => unit
let unsafeDeleteKey: (t<string>, string) => unit

/**
Returns an array of key/value pairs in the given dictionary (ES2017).
Expand Down Expand Up @@ -170,4 +170,4 @@ let salePrices = Js.Dict.map(discount, prices)
salePrices == Js.Dict.fromList(list{("pen", 0.90), ("book", 4.50), ("stapler", 6.30)})
```
*/
let map: ((. 'a) => 'b, t<'a>) => t<'b>
let map: ('a => 'b, t<'a>) => t<'b>
24 changes: 12 additions & 12 deletions js/src/js_list.res
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ let rev = l => revAppend(l, list{})
let rec mapRevAux = (f, acc, ls) =>
switch ls {
| list{} => acc
| list{a, ...l} => mapRevAux(f, list{f(. a), ...acc}, l)
| list{a, ...l} => mapRevAux(f, list{f(a), ...acc}, l)
}

let mapRev = (f, ls) => mapRevAux(f, list{}, ls)
Expand All @@ -89,15 +89,15 @@ let rec iter = (f, x) =>
switch x {
| list{} => ()
| list{a, ...l} =>
f(. a)
f(a)
iter(f, l)
}

let rec iteri = (i, f, x) =>
switch x {
| list{} => ()
| list{a, ...l} =>
f(. i, a)
f(i, a)
iteri(i + 1, f, l)
}

Expand All @@ -106,15 +106,15 @@ let iteri = (f, l) => iteri(0, f, l)
let rec foldLeft = (f, accu, l) =>
switch l {
| list{} => accu
| list{a, ...l} => foldLeft(f, f(. accu, a), l)
| list{a, ...l} => foldLeft(f, f(accu, a), l)
}

let foldRightMaxStack = 1000

let rec tailLoop = (f, acc, x) =>
switch x {
| list{} => acc
| list{h, ...t} => tailLoop(f, f(. h, acc), t)
| list{h, ...t} => tailLoop(f, f(h, acc), t)
}

let foldRight = (f, l, init) => {
Expand All @@ -123,9 +123,9 @@ let foldRight = (f, l, init) => {
| list{} => init
| list{h, ...t} =>
if n < foldRightMaxStack {
f(. h, loop(n + 1, t))
f(h, loop(n + 1, t))
} else {
f(. h, tailLoop(f, init, rev(t)))
f(h, tailLoop(f, init, rev(t)))
}
}

Expand All @@ -144,19 +144,19 @@ let rec filterRevAux = (f, acc, xs) =>
switch xs {
| list{} => acc
| list{y, ...ys} =>
switch f(. y) {
switch f(y) {
| false => filterRevAux(f, acc, ys)
| true => filterRevAux(f, list{y, ...acc}, ys)
}
}

let filter = (f, xs) => rev(filterRevAux(f, list{}, xs))

let rec filterMapRevAux = (f: (. 'a) => option<'b>, acc, xs) =>
let rec filterMapRevAux = (f: 'a => option<'b>, acc, xs) =>
switch xs {
| list{} => acc
| list{y, ...ys} =>
switch f(. y) {
switch f(y) {
| None => filterMapRevAux(f, acc, ys)
| Some(z) => filterMapRevAux(f, list{z, ...acc}, ys)
}
Expand All @@ -170,7 +170,7 @@ let rec countByAux = (f, acc, xs) =>
| list{y, ...ys} =>
countByAux(
f,
if f(. y) {
if f(y) {
acc + 1
} else {
acc
Expand Down Expand Up @@ -204,7 +204,7 @@ let rec equal = (cmp, xs, ys) =>
switch (xs, ys) {
| (list{}, list{}) => true
| (list{x, ...xs}, list{y, ...ys}) =>
if cmp(. x, y) {
if cmp(x, y) {
equal(cmp, xs, ys)
} else {
false
Expand Down
Loading