mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-23 14:35:12 +00:00
roc format builtins
This commit is contained in:
parent
01434c8e28
commit
7e12171b76
7 changed files with 344 additions and 357 deletions
|
@ -1,24 +1,22 @@
|
||||||
interface Dict
|
interface Dict
|
||||||
exposes
|
exposes [
|
||||||
[
|
empty,
|
||||||
empty,
|
single,
|
||||||
single,
|
get,
|
||||||
get,
|
walk,
|
||||||
walk,
|
insert,
|
||||||
insert,
|
len,
|
||||||
len,
|
remove,
|
||||||
remove,
|
contains,
|
||||||
contains,
|
keys,
|
||||||
keys,
|
values,
|
||||||
values,
|
union,
|
||||||
union,
|
intersection,
|
||||||
intersection,
|
difference,
|
||||||
difference,
|
]
|
||||||
]
|
imports [
|
||||||
imports
|
Bool.{ Bool },
|
||||||
[
|
]
|
||||||
Bool.{ Bool },
|
|
||||||
]
|
|
||||||
|
|
||||||
## A [dictionary](https://en.wikipedia.org/wiki/Associative_array) that lets you can associate keys with values.
|
## A [dictionary](https://en.wikipedia.org/wiki/Associative_array) that lets you can associate keys with values.
|
||||||
##
|
##
|
||||||
|
|
|
@ -1,35 +1,33 @@
|
||||||
interface Encode
|
interface Encode
|
||||||
exposes
|
exposes [
|
||||||
[
|
Encoder,
|
||||||
Encoder,
|
Encoding,
|
||||||
Encoding,
|
toEncoder,
|
||||||
toEncoder,
|
EncoderFormatting,
|
||||||
EncoderFormatting,
|
u8,
|
||||||
u8,
|
u16,
|
||||||
u16,
|
u32,
|
||||||
u32,
|
u64,
|
||||||
u64,
|
u128,
|
||||||
u128,
|
i8,
|
||||||
i8,
|
i16,
|
||||||
i16,
|
i32,
|
||||||
i32,
|
i64,
|
||||||
i64,
|
i128,
|
||||||
i128,
|
f32,
|
||||||
f32,
|
f64,
|
||||||
f64,
|
dec,
|
||||||
dec,
|
bool,
|
||||||
bool,
|
string,
|
||||||
string,
|
list,
|
||||||
list,
|
record,
|
||||||
record,
|
tag,
|
||||||
tag,
|
custom,
|
||||||
custom,
|
appendWith,
|
||||||
appendWith,
|
append,
|
||||||
append,
|
toBytes,
|
||||||
toBytes,
|
]
|
||||||
]
|
imports []
|
||||||
imports
|
|
||||||
[]
|
|
||||||
|
|
||||||
Encoder fmt := List U8, fmt -> List U8 | fmt has EncoderFormatting
|
Encoder fmt := List U8, fmt -> List U8 | fmt has EncoderFormatting
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,33 @@
|
||||||
interface Json
|
interface Json
|
||||||
exposes
|
exposes [
|
||||||
[
|
Json,
|
||||||
Json,
|
format,
|
||||||
format,
|
]
|
||||||
]
|
imports [
|
||||||
imports
|
Encode.{
|
||||||
[
|
Encoder,
|
||||||
Encode.{
|
custom,
|
||||||
Encoder,
|
appendWith,
|
||||||
custom,
|
u8,
|
||||||
appendWith,
|
u16,
|
||||||
u8,
|
u32,
|
||||||
u16,
|
u64,
|
||||||
u32,
|
u128,
|
||||||
u64,
|
i8,
|
||||||
u128,
|
i16,
|
||||||
i8,
|
i32,
|
||||||
i16,
|
i64,
|
||||||
i32,
|
i128,
|
||||||
i64,
|
f32,
|
||||||
i128,
|
f64,
|
||||||
f32,
|
dec,
|
||||||
f64,
|
bool,
|
||||||
dec,
|
string,
|
||||||
bool,
|
list,
|
||||||
string,
|
record,
|
||||||
list,
|
tag,
|
||||||
record,
|
},
|
||||||
tag,
|
]
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
Json := {}
|
Json := {}
|
||||||
|
|
||||||
|
|
|
@ -1,63 +1,61 @@
|
||||||
interface List
|
interface List
|
||||||
exposes
|
exposes [
|
||||||
[
|
isEmpty,
|
||||||
isEmpty,
|
get,
|
||||||
get,
|
set,
|
||||||
set,
|
replace,
|
||||||
replace,
|
append,
|
||||||
append,
|
map,
|
||||||
map,
|
len,
|
||||||
len,
|
withCapacity,
|
||||||
withCapacity,
|
iterate,
|
||||||
iterate,
|
walkBackwards,
|
||||||
walkBackwards,
|
concat,
|
||||||
concat,
|
first,
|
||||||
first,
|
single,
|
||||||
single,
|
repeat,
|
||||||
repeat,
|
reverse,
|
||||||
reverse,
|
prepend,
|
||||||
prepend,
|
join,
|
||||||
join,
|
keepIf,
|
||||||
keepIf,
|
contains,
|
||||||
contains,
|
sum,
|
||||||
sum,
|
walk,
|
||||||
walk,
|
last,
|
||||||
last,
|
keepOks,
|
||||||
keepOks,
|
keepErrs,
|
||||||
keepErrs,
|
mapWithIndex,
|
||||||
mapWithIndex,
|
map2,
|
||||||
map2,
|
map3,
|
||||||
map3,
|
product,
|
||||||
product,
|
walkUntil,
|
||||||
walkUntil,
|
range,
|
||||||
range,
|
sortWith,
|
||||||
sortWith,
|
drop,
|
||||||
drop,
|
swap,
|
||||||
swap,
|
dropAt,
|
||||||
dropAt,
|
dropLast,
|
||||||
dropLast,
|
min,
|
||||||
min,
|
max,
|
||||||
max,
|
map4,
|
||||||
map4,
|
dropFirst,
|
||||||
dropFirst,
|
joinMap,
|
||||||
joinMap,
|
any,
|
||||||
any,
|
takeFirst,
|
||||||
takeFirst,
|
takeLast,
|
||||||
takeLast,
|
find,
|
||||||
find,
|
findIndex,
|
||||||
findIndex,
|
sublist,
|
||||||
sublist,
|
intersperse,
|
||||||
intersperse,
|
split,
|
||||||
split,
|
all,
|
||||||
all,
|
dropIf,
|
||||||
dropIf,
|
sortAsc,
|
||||||
sortAsc,
|
sortDesc,
|
||||||
sortDesc,
|
]
|
||||||
]
|
imports [
|
||||||
imports
|
Bool.{ Bool },
|
||||||
[
|
]
|
||||||
Bool.{ Bool },
|
|
||||||
]
|
|
||||||
|
|
||||||
## Types
|
## Types
|
||||||
## A sequential list of values.
|
## A sequential list of values.
|
||||||
|
|
|
@ -1,153 +1,151 @@
|
||||||
interface Num
|
interface Num
|
||||||
exposes
|
exposes [
|
||||||
[
|
Num,
|
||||||
Num,
|
Int,
|
||||||
Int,
|
Frac,
|
||||||
Frac,
|
Integer,
|
||||||
Integer,
|
FloatingPoint,
|
||||||
FloatingPoint,
|
I128,
|
||||||
I128,
|
I64,
|
||||||
I64,
|
I32,
|
||||||
I32,
|
I16,
|
||||||
I16,
|
I8,
|
||||||
I8,
|
U128,
|
||||||
U128,
|
U64,
|
||||||
U64,
|
U32,
|
||||||
U32,
|
U16,
|
||||||
U16,
|
U8,
|
||||||
U8,
|
Signed128,
|
||||||
Signed128,
|
Signed64,
|
||||||
Signed64,
|
Signed32,
|
||||||
Signed32,
|
Signed16,
|
||||||
Signed16,
|
Signed8,
|
||||||
Signed8,
|
Unsigned128,
|
||||||
Unsigned128,
|
Unsigned64,
|
||||||
Unsigned64,
|
Unsigned32,
|
||||||
Unsigned32,
|
Unsigned16,
|
||||||
Unsigned16,
|
Unsigned8,
|
||||||
Unsigned8,
|
Nat,
|
||||||
Nat,
|
Dec,
|
||||||
Dec,
|
F32,
|
||||||
F32,
|
F64,
|
||||||
F64,
|
Natural,
|
||||||
Natural,
|
Decimal,
|
||||||
Decimal,
|
Binary32,
|
||||||
Binary32,
|
Binary64,
|
||||||
Binary64,
|
abs,
|
||||||
abs,
|
neg,
|
||||||
neg,
|
add,
|
||||||
add,
|
sub,
|
||||||
sub,
|
mul,
|
||||||
mul,
|
isLt,
|
||||||
isLt,
|
isLte,
|
||||||
isLte,
|
isGt,
|
||||||
isGt,
|
isGte,
|
||||||
isGte,
|
sin,
|
||||||
sin,
|
cos,
|
||||||
cos,
|
tan,
|
||||||
tan,
|
atan,
|
||||||
atan,
|
acos,
|
||||||
acos,
|
asin,
|
||||||
asin,
|
isZero,
|
||||||
isZero,
|
isEven,
|
||||||
isEven,
|
isOdd,
|
||||||
isOdd,
|
toFrac,
|
||||||
toFrac,
|
isPositive,
|
||||||
isPositive,
|
isNegative,
|
||||||
isNegative,
|
rem,
|
||||||
rem,
|
remChecked,
|
||||||
remChecked,
|
div,
|
||||||
div,
|
divChecked,
|
||||||
divChecked,
|
sqrt,
|
||||||
sqrt,
|
sqrtChecked,
|
||||||
sqrtChecked,
|
log,
|
||||||
log,
|
logChecked,
|
||||||
logChecked,
|
round,
|
||||||
round,
|
ceiling,
|
||||||
ceiling,
|
floor,
|
||||||
floor,
|
compare,
|
||||||
compare,
|
pow,
|
||||||
pow,
|
powInt,
|
||||||
powInt,
|
addWrap,
|
||||||
addWrap,
|
addChecked,
|
||||||
addChecked,
|
addSaturated,
|
||||||
addSaturated,
|
bitwiseAnd,
|
||||||
bitwiseAnd,
|
bitwiseXor,
|
||||||
bitwiseXor,
|
bitwiseOr,
|
||||||
bitwiseOr,
|
shiftLeftBy,
|
||||||
shiftLeftBy,
|
shiftRightBy,
|
||||||
shiftRightBy,
|
shiftRightZfBy,
|
||||||
shiftRightZfBy,
|
subWrap,
|
||||||
subWrap,
|
subChecked,
|
||||||
subChecked,
|
subSaturated,
|
||||||
subSaturated,
|
mulWrap,
|
||||||
mulWrap,
|
mulSaturated,
|
||||||
mulSaturated,
|
mulChecked,
|
||||||
mulChecked,
|
intCast,
|
||||||
intCast,
|
bytesToU16,
|
||||||
bytesToU16,
|
bytesToU32,
|
||||||
bytesToU32,
|
divCeil,
|
||||||
divCeil,
|
divCeilChecked,
|
||||||
divCeilChecked,
|
divTrunc,
|
||||||
divTrunc,
|
divTruncChecked,
|
||||||
divTruncChecked,
|
toStr,
|
||||||
toStr,
|
isMultipleOf,
|
||||||
isMultipleOf,
|
minI8,
|
||||||
minI8,
|
maxI8,
|
||||||
maxI8,
|
minU8,
|
||||||
minU8,
|
maxU8,
|
||||||
maxU8,
|
minI16,
|
||||||
minI16,
|
maxI16,
|
||||||
maxI16,
|
minU16,
|
||||||
minU16,
|
maxU16,
|
||||||
maxU16,
|
minI32,
|
||||||
minI32,
|
maxI32,
|
||||||
maxI32,
|
minU32,
|
||||||
minU32,
|
maxU32,
|
||||||
maxU32,
|
minI64,
|
||||||
minI64,
|
maxI64,
|
||||||
maxI64,
|
minU64,
|
||||||
minU64,
|
maxU64,
|
||||||
maxU64,
|
minI128,
|
||||||
minI128,
|
maxI128,
|
||||||
maxI128,
|
minU128,
|
||||||
minU128,
|
maxU128,
|
||||||
maxU128,
|
minF32,
|
||||||
minF32,
|
maxF32,
|
||||||
maxF32,
|
minF64,
|
||||||
minF64,
|
maxF64,
|
||||||
maxF64,
|
toI8,
|
||||||
toI8,
|
toI8Checked,
|
||||||
toI8Checked,
|
toI16,
|
||||||
toI16,
|
toI16Checked,
|
||||||
toI16Checked,
|
toI32,
|
||||||
toI32,
|
toI32Checked,
|
||||||
toI32Checked,
|
toI64,
|
||||||
toI64,
|
toI64Checked,
|
||||||
toI64Checked,
|
toI128,
|
||||||
toI128,
|
toI128Checked,
|
||||||
toI128Checked,
|
toU8,
|
||||||
toU8,
|
toU8Checked,
|
||||||
toU8Checked,
|
toU16,
|
||||||
toU16,
|
toU16Checked,
|
||||||
toU16Checked,
|
toU32,
|
||||||
toU32,
|
toU32Checked,
|
||||||
toU32Checked,
|
toU64,
|
||||||
toU64,
|
toU64Checked,
|
||||||
toU64Checked,
|
toU128,
|
||||||
toU128,
|
toU128Checked,
|
||||||
toU128Checked,
|
toNat,
|
||||||
toNat,
|
toNatChecked,
|
||||||
toNatChecked,
|
toF32,
|
||||||
toF32,
|
toF32Checked,
|
||||||
toF32Checked,
|
toF64,
|
||||||
toF64,
|
toF64Checked,
|
||||||
toF64Checked,
|
]
|
||||||
]
|
imports [
|
||||||
imports
|
Bool.{ Bool },
|
||||||
[
|
]
|
||||||
Bool.{ Bool },
|
|
||||||
]
|
|
||||||
|
|
||||||
## Represents a number that could be either an [Int] or a [Frac].
|
## Represents a number that could be either an [Int] or a [Frac].
|
||||||
##
|
##
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
interface Set
|
interface Set
|
||||||
exposes
|
exposes [
|
||||||
[
|
empty,
|
||||||
empty,
|
single,
|
||||||
single,
|
walk,
|
||||||
walk,
|
insert,
|
||||||
insert,
|
len,
|
||||||
len,
|
remove,
|
||||||
remove,
|
contains,
|
||||||
contains,
|
toList,
|
||||||
toList,
|
fromList,
|
||||||
fromList,
|
union,
|
||||||
union,
|
intersection,
|
||||||
intersection,
|
difference,
|
||||||
difference,
|
]
|
||||||
]
|
|
||||||
imports [List, Bool.{ Bool }, Dict.{ values }]
|
imports [List, Bool.{ Bool }, Dict.{ values }]
|
||||||
|
|
||||||
## An empty set.
|
## An empty set.
|
||||||
|
|
|
@ -1,47 +1,46 @@
|
||||||
interface Str
|
interface Str
|
||||||
exposes
|
exposes [
|
||||||
[
|
Utf8Problem,
|
||||||
Utf8Problem,
|
Utf8ByteProblem,
|
||||||
Utf8ByteProblem,
|
concat,
|
||||||
concat,
|
isEmpty,
|
||||||
isEmpty,
|
joinWith,
|
||||||
joinWith,
|
split,
|
||||||
split,
|
repeat,
|
||||||
repeat,
|
countGraphemes,
|
||||||
countGraphemes,
|
countUtf8Bytes,
|
||||||
countUtf8Bytes,
|
startsWithScalar,
|
||||||
startsWithScalar,
|
toUtf8,
|
||||||
toUtf8,
|
fromUtf8,
|
||||||
fromUtf8,
|
fromUtf8Range,
|
||||||
fromUtf8Range,
|
startsWith,
|
||||||
startsWith,
|
endsWith,
|
||||||
endsWith,
|
trim,
|
||||||
trim,
|
trimLeft,
|
||||||
trimLeft,
|
trimRight,
|
||||||
trimRight,
|
toDec,
|
||||||
toDec,
|
toF64,
|
||||||
toF64,
|
toF32,
|
||||||
toF32,
|
toNat,
|
||||||
toNat,
|
toU128,
|
||||||
toU128,
|
toI128,
|
||||||
toI128,
|
toU64,
|
||||||
toU64,
|
toI64,
|
||||||
toI64,
|
toU32,
|
||||||
toU32,
|
toI32,
|
||||||
toI32,
|
toU16,
|
||||||
toU16,
|
toI16,
|
||||||
toI16,
|
toU8,
|
||||||
toU8,
|
toI8,
|
||||||
toI8,
|
toScalars,
|
||||||
toScalars,
|
splitFirst,
|
||||||
splitFirst,
|
splitLast,
|
||||||
splitLast,
|
walkUtf8WithIndex,
|
||||||
walkUtf8WithIndex,
|
reserve,
|
||||||
reserve,
|
appendScalar,
|
||||||
appendScalar,
|
walkScalars,
|
||||||
walkScalars,
|
walkScalarsUntil,
|
||||||
walkScalarsUntil,
|
]
|
||||||
]
|
|
||||||
imports [Bool.{ Bool }, Result.{ Result }]
|
imports [Bool.{ Bool }, Result.{ Result }]
|
||||||
|
|
||||||
## # Types
|
## # Types
|
||||||
|
@ -118,15 +117,14 @@ interface Str
|
||||||
## and you can use it as many times as you like inside a string. The name
|
## and you can use it as many times as you like inside a string. The name
|
||||||
## between the parentheses must refer to a `Str` value that is currently in
|
## between the parentheses must refer to a `Str` value that is currently in
|
||||||
## scope, and it must be a name - it can't be an arbitrary expression like a function call.
|
## scope, and it must be a name - it can't be an arbitrary expression like a function call.
|
||||||
Utf8ByteProblem :
|
Utf8ByteProblem : [
|
||||||
[
|
InvalidStartByte,
|
||||||
InvalidStartByte,
|
UnexpectedEndOfSequence,
|
||||||
UnexpectedEndOfSequence,
|
ExpectedContinuation,
|
||||||
ExpectedContinuation,
|
OverlongEncoding,
|
||||||
OverlongEncoding,
|
CodepointTooLarge,
|
||||||
CodepointTooLarge,
|
EncodesSurrogateHalf,
|
||||||
EncodesSurrogateHalf,
|
]
|
||||||
]
|
|
||||||
|
|
||||||
Utf8Problem : { byteIndex : Nat, problem : Utf8ByteProblem }
|
Utf8Problem : { byteIndex : Nat, problem : Utf8ByteProblem }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue