mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 03:42:17 +00:00
Update roc files to use new opaque bools
This commit is contained in:
parent
9717747a54
commit
610c529ba8
19 changed files with 114 additions and 114 deletions
|
@ -69,7 +69,7 @@ interface Dict
|
|||
##
|
||||
## When comparing two dictionaries for equality, they are `==` only if their both their contents and their
|
||||
## orderings match. This preserves the property that if `dict1 == dict2`, you should be able to rely on
|
||||
## `fn dict1 == fn dict2` also being `True`, even if `fn` relies on the dictionary's ordering.
|
||||
## `fn dict1 == fn dict2` also being `Bool.true`, even if `fn` relies on the dictionary's ordering.
|
||||
Dict k v := List [Pair k v]
|
||||
|
||||
## An empty dictionary.
|
||||
|
@ -130,8 +130,8 @@ contains = \@Dict list, needle ->
|
|||
Continue {}
|
||||
|
||||
when List.iterate list {} step is
|
||||
Continue _ -> False
|
||||
Break _ -> True
|
||||
Continue _ -> Bool.false
|
||||
Break _ -> Bool.true
|
||||
|
||||
single : k, v -> Dict k v
|
||||
single = \key, value ->
|
||||
|
|
|
@ -307,14 +307,14 @@ decodeBool = Decode.custom \bytes, @Json {} ->
|
|||
if
|
||||
maybeFalse == [asciiByte 'f', asciiByte 'a', asciiByte 'l', asciiByte 's', asciiByte 'e']
|
||||
then
|
||||
{ result: Ok False, rest: afterFalse }
|
||||
{ result: Ok Bool.false, rest: afterFalse }
|
||||
else
|
||||
{ before: maybeTrue, others: afterTrue } = List.split bytes 4
|
||||
|
||||
if
|
||||
maybeTrue == [asciiByte 't', asciiByte 'r', asciiByte 'u', asciiByte 'e']
|
||||
then
|
||||
{ result: Ok True, rest: afterTrue }
|
||||
{ result: Ok Bool.true, rest: afterTrue }
|
||||
else
|
||||
{ result: Err TooShort, rest: bytes }
|
||||
|
||||
|
|
|
@ -441,7 +441,7 @@ product : List (Num a) -> Num a
|
|||
product = \list ->
|
||||
List.walk list 1 Num.mul
|
||||
|
||||
## Run the given predicate on each element of the list, returning `True` if
|
||||
## Run the given predicate on each element of the list, returning `Bool.true` if
|
||||
## any of the elements satisfy it.
|
||||
any : List a, (a -> Bool) -> Bool
|
||||
any = \list, predicate ->
|
||||
|
@ -452,10 +452,10 @@ any = \list, predicate ->
|
|||
Continue {}
|
||||
|
||||
when List.iterate list {} looper is
|
||||
Continue {} -> False
|
||||
Break {} -> True
|
||||
Continue {} -> Bool.false
|
||||
Break {} -> Bool.true
|
||||
|
||||
## Run the given predicate on each element of the list, returning `True` if
|
||||
## Run the given predicate on each element of the list, returning `Bool.true` if
|
||||
## all of the elements satisfy it.
|
||||
all : List a, (a -> Bool) -> Bool
|
||||
all = \list, predicate ->
|
||||
|
@ -466,11 +466,11 @@ all = \list, predicate ->
|
|||
Break {}
|
||||
|
||||
when List.iterate list {} looper is
|
||||
Continue {} -> True
|
||||
Break {} -> False
|
||||
Continue {} -> Bool.true
|
||||
Break {} -> Bool.false
|
||||
|
||||
## Run the given function on each element of a list, and return all the
|
||||
## elements for which the function returned `True`.
|
||||
## elements for which the function returned `Bool.true`.
|
||||
##
|
||||
## >>> List.keepIf [1, 2, 3, 4] (\num -> num > 2)
|
||||
##
|
||||
|
@ -507,7 +507,7 @@ keepIfHelp = \list, predicate, kept, index, length ->
|
|||
List.takeFirst list kept
|
||||
|
||||
## Run the given function on each element of a list, and return all the
|
||||
## elements for which the function returned `False`.
|
||||
## elements for which the function returned `Bool.false`.
|
||||
##
|
||||
## >>> List.dropIf [1, 2, 3, 4] (\num -> num > 2)
|
||||
##
|
||||
|
@ -875,24 +875,24 @@ intersperse = \list, sep ->
|
|||
|
||||
List.dropLast newList
|
||||
|
||||
## Returns `True` if the first list starts with the second list.
|
||||
## Returns `Bool.true` if the first list starts with the second list.
|
||||
##
|
||||
## If the second list is empty, this always returns `True`; every list
|
||||
## If the second list is empty, this always returns `Bool.true`; every list
|
||||
## is considered to "start with" an empty list.
|
||||
##
|
||||
## If the first list is empty, this only returns `True` if the second list is empty.
|
||||
## If the first list is empty, this only returns `Bool.true` if the second list is empty.
|
||||
startsWith : List elem, List elem -> Bool
|
||||
startsWith = \list, prefix ->
|
||||
# TODO once we have seamless slices, verify that this wouldn't
|
||||
# have better performance with a function like List.compareSublists
|
||||
prefix == List.sublist list { start: 0, len: List.len prefix }
|
||||
|
||||
## Returns `True` if the first list ends with the second list.
|
||||
## Returns `Bool.true` if the first list ends with the second list.
|
||||
##
|
||||
## If the second list is empty, this always returns `True`; every list
|
||||
## If the second list is empty, this always returns `Bool.true`; every list
|
||||
## is considered to "end with" an empty list.
|
||||
##
|
||||
## If the first list is empty, this only returns `True` if the second list is empty.
|
||||
## If the first list is empty, this only returns `Bool.true` if the second list is empty.
|
||||
endsWith : List elem, List elem -> Bool
|
||||
endsWith = \list, suffix ->
|
||||
# TODO once we have seamless slices, verify that this wouldn't
|
||||
|
|
|
@ -346,14 +346,14 @@ Int range : Num (Integer range)
|
|||
##
|
||||
## wasItPrecise = 0.1 + 0.2 == 0.3
|
||||
##
|
||||
## The value of `wasItPrecise` here will be `True`, because Roc uses [Dec]
|
||||
## The value of `wasItPrecise` here will be `Bool.true`, because Roc uses [Dec]
|
||||
## by default when there are no types specified.
|
||||
##
|
||||
## In contrast, suppose we use `f32` or `f64` for one of these numbers:
|
||||
##
|
||||
## wasItPrecise = 0.1f64 + 0.2 == 0.3
|
||||
##
|
||||
## Here, `wasItPrecise` will be `False` because the entire calculation will have
|
||||
## Here, `wasItPrecise` will be `Bool.false` because the entire calculation will have
|
||||
## been done in a base-2 floating point calculation, which causes noticeable
|
||||
## precision loss in this case.
|
||||
##
|
||||
|
@ -534,45 +534,45 @@ bytesToU32 = \bytes, index ->
|
|||
|
||||
compare : Num a, Num a -> [LT, EQ, GT]
|
||||
|
||||
## Returns `True` if the first number is less than the second.
|
||||
## Returns `Bool.true` if the first number is less than the second.
|
||||
##
|
||||
## `a < b` is shorthand for `Num.isLt a b`.
|
||||
##
|
||||
## If either argument is [*NaN*](Num.isNaN), returns `False` no matter what. (*NaN*
|
||||
## If either argument is [*NaN*](Num.isNaN), returns `Bool.false` no matter what. (*NaN*
|
||||
## is [defined to be unordered](https://en.wikipedia.org/wiki/NaN#Comparison_with_NaN).)
|
||||
##
|
||||
## >>> 5
|
||||
## >>> |> Num.isLt 6
|
||||
isLt : Num a, Num a -> Bool
|
||||
|
||||
## Returns `True` if the first number is greater than the second.
|
||||
## Returns `Bool.true` if the first number is greater than the second.
|
||||
##
|
||||
## `a > b` is shorthand for `Num.isGt a b`.
|
||||
##
|
||||
## If either argument is [*NaN*](Num.isNaN), returns `False` no matter what. (*NaN*
|
||||
## If either argument is [*NaN*](Num.isNaN), returns `Bool.false` no matter what. (*NaN*
|
||||
## is [defined to be unordered](https://en.wikipedia.org/wiki/NaN#Comparison_with_NaN).)
|
||||
##
|
||||
## >>> 6
|
||||
## >>> |> Num.isGt 5
|
||||
isGt : Num a, Num a -> Bool
|
||||
|
||||
## Returns `True` if the first number is less than or equal to the second.
|
||||
## Returns `Bool.true` if the first number is less than or equal to the second.
|
||||
##
|
||||
## `a <= b` is shorthand for `Num.isLte a b`.
|
||||
##
|
||||
## If either argument is [*NaN*](Num.isNaN), returns `False` no matter what. (*NaN*
|
||||
## If either argument is [*NaN*](Num.isNaN), returns `Bool.false` no matter what. (*NaN*
|
||||
## is [defined to be unordered](https://en.wikipedia.org/wiki/NaN#Comparison_with_NaN).)
|
||||
isLte : Num a, Num a -> Bool
|
||||
|
||||
## Returns `True` if the first number is greater than or equal to the second.
|
||||
## Returns `Bool.true` if the first number is greater than or equal to the second.
|
||||
##
|
||||
## `a >= b` is shorthand for `Num.isGte a b`.
|
||||
##
|
||||
## If either argument is [*NaN*](Num.isNaN), returns `False` no matter what. (*NaN*
|
||||
## If either argument is [*NaN*](Num.isNaN), returns `Bool.false` no matter what. (*NaN*
|
||||
## is [defined to be unordered](https://en.wikipedia.org/wiki/NaN#Comparison_with_NaN).)
|
||||
isGte : Num a, Num a -> Bool
|
||||
|
||||
## Returns `True` if the number is `0`, and `False` otherwise.
|
||||
## Returns `Bool.true` if the number is `0`, and `Bool.false` otherwise.
|
||||
isZero : Num a -> Bool
|
||||
isZero = \x -> x == 0
|
||||
|
||||
|
@ -1265,34 +1265,34 @@ toF32Checked : Num * -> Result F32 [OutOfBounds]*
|
|||
toF64Checked : Num * -> Result F64 [OutOfBounds]*
|
||||
|
||||
# Special Floating-Point operations
|
||||
## When given a [F64] or [F32] value, returns `False` if that value is
|
||||
## [*NaN*](Num.isNaN), ∞ or -∞, and `True` otherwise.
|
||||
## When given a [F64] or [F32] value, returns `Bool.false` if that value is
|
||||
## [*NaN*](Num.isNaN), ∞ or -∞, and `Bool.true` otherwise.
|
||||
##
|
||||
## Always returns `True` when given a [Dec].
|
||||
## Always returns `Bool.true` when given a [Dec].
|
||||
##
|
||||
## This is the opposite of #isInfinite, except when given [*NaN*](Num.isNaN). Both
|
||||
## #isFinite and #isInfinite return `False` for [*NaN*](Num.isNaN).
|
||||
## #isFinite and #isInfinite return `Bool.false` for [*NaN*](Num.isNaN).
|
||||
# isFinite : Frac * -> Bool
|
||||
## When given a [F64] or [F32] value, returns `True` if that value is either
|
||||
## ∞ or -∞, and `False` otherwise.
|
||||
## When given a [F64] or [F32] value, returns `Bool.true` if that value is either
|
||||
## ∞ or -∞, and `Bool.false` otherwise.
|
||||
##
|
||||
## Always returns `False` when given a [Dec].
|
||||
## Always returns `Bool.false` when given a [Dec].
|
||||
##
|
||||
## This is the opposite of #isFinite, except when given [*NaN*](Num.isNaN). Both
|
||||
## #isFinite and #isInfinite return `False` for [*NaN*](Num.isNaN).
|
||||
## #isFinite and #isInfinite return `Bool.false` for [*NaN*](Num.isNaN).
|
||||
# isInfinite : Frac * -> Bool
|
||||
## When given a [F64] or [F32] value, returns `True` if that value is
|
||||
## *NaN* ([not a number](https://en.wikipedia.org/wiki/NaN)), and `False` otherwise.
|
||||
## When given a [F64] or [F32] value, returns `Bool.true` if that value is
|
||||
## *NaN* ([not a number](https://en.wikipedia.org/wiki/NaN)), and `Bool.false` otherwise.
|
||||
##
|
||||
## Always returns `False` when given a [Dec].
|
||||
## Always returns `Bool.false` when given a [Dec].
|
||||
##
|
||||
## >>> Num.isNaN 12.3
|
||||
##
|
||||
## >>> Num.isNaN (Num.pow -1 0.5)
|
||||
##
|
||||
## *NaN* is unusual from other numberic values in that:
|
||||
## * *NaN* is not equal to any other number, even itself. [Bool.isEq] always returns `False` if either argument is *NaN*.
|
||||
## * *NaN* has no ordering, so [isLt], [isLte], [isGt], and [isGte] always return `False` if either argument is *NaN*.
|
||||
## * *NaN* is not equal to any other number, even itself. [Bool.isEq] always returns `Bool.false` if either argument is *NaN*.
|
||||
## * *NaN* has no ordering, so [isLt], [isLte], [isGt], and [isGte] always return `Bool.false` if either argument is *NaN*.
|
||||
##
|
||||
## These rules come from the [IEEE-754](https://en.wikipedia.org/wiki/IEEE_754)
|
||||
## floating point standard. Because almost all modern processors are built to
|
||||
|
@ -1306,12 +1306,12 @@ toF64Checked : Num * -> Result F64 [OutOfBounds]*
|
|||
# isNaN : Frac * -> Bool
|
||||
## Returns the higher of two numbers.
|
||||
##
|
||||
## If either argument is [*NaN*](Num.isNaN), returns `False` no matter what. (*NaN*
|
||||
## If either argument is [*NaN*](Num.isNaN), returns `Bool.false` no matter what. (*NaN*
|
||||
## is [defined to be unordered](https://en.wikipedia.org/wiki/NaN#Comparison_with_NaN).)
|
||||
# max : Num a, Num a -> Num a
|
||||
## Returns the lower of two numbers.
|
||||
##
|
||||
## If either argument is [*NaN*](Num.isNaN), returns `False` no matter what. (*NaN*
|
||||
## If either argument is [*NaN*](Num.isNaN), returns `Bool.false` no matter what. (*NaN*
|
||||
## is [defined to be unordered](https://en.wikipedia.org/wiki/NaN#Comparison_with_NaN).)
|
||||
# min : Num a, Num a -> Num a
|
||||
# Branchless implementation that works for all numeric types:
|
||||
|
|
|
@ -6,23 +6,23 @@ interface Result
|
|||
## okay, or else there was an error of some sort.
|
||||
Result ok err : [Ok ok, Err err]
|
||||
|
||||
## Return True if the result indicates a success, else return False
|
||||
## Return `Bool.true` if the result indicates a success, else return `Bool.false`
|
||||
##
|
||||
## >>> Result.isOk (Ok 5)
|
||||
isOk : Result ok err -> Bool
|
||||
isOk = \result ->
|
||||
when result is
|
||||
Ok _ -> True
|
||||
Err _ -> False
|
||||
Ok _ -> Bool.true
|
||||
Err _ -> Bool.false
|
||||
|
||||
## Return True if the result indicates a failure, else return False
|
||||
## Return `Bool.true` if the result indicates a failure, else return `Bool.false`
|
||||
##
|
||||
## >>> Result.isErr (Err "uh oh")
|
||||
isErr : Result ok err -> Bool
|
||||
isErr = \result ->
|
||||
when result is
|
||||
Ok _ -> False
|
||||
Err _ -> True
|
||||
Ok _ -> Bool.false
|
||||
Err _ -> Bool.true
|
||||
|
||||
## If the result is `Ok`, return the value it holds. Otherwise, return
|
||||
## the given default value.
|
||||
|
|
|
@ -131,7 +131,7 @@ Utf8ByteProblem : [
|
|||
|
||||
Utf8Problem : { byteIndex : Nat, problem : Utf8ByteProblem }
|
||||
|
||||
## Returns `True` if the string is empty, and `False` otherwise.
|
||||
## Returns `Bool.true` if the string is empty, and `Bool.false` otherwise.
|
||||
##
|
||||
## >>> Str.isEmpty "hi!"
|
||||
##
|
||||
|
@ -167,10 +167,10 @@ repeat : Str, Nat -> Str
|
|||
countGraphemes : Str -> Nat
|
||||
|
||||
## If the string begins with a [Unicode code point](http://www.unicode.org/glossary/#code_point)
|
||||
## equal to the given [U32], return `True`. Otherwise return `False`.
|
||||
## equal to the given [U32], return `Bool.true`. Otherwise return `Bool.false`.
|
||||
##
|
||||
## If the given [Str] is empty, or if the given [U32] is not a valid
|
||||
## code point, this will return `False`.
|
||||
## code point, this will return `Bool.false`.
|
||||
##
|
||||
## **Performance Note:** This runs slightly faster than [Str.startsWith], so
|
||||
## if you want to check whether a string begins with something that's representable
|
||||
|
@ -452,9 +452,9 @@ matchesAtHelp = \haystack, haystackIndex, needle, needleIndex, endIndex ->
|
|||
if Str.getUnsafe haystack haystackIndex == Str.getUnsafe needle needleIndex then
|
||||
matchesAtHelp haystack (haystackIndex + 1) needle (needleIndex + 1) endIndex
|
||||
else
|
||||
False
|
||||
Bool.false
|
||||
else
|
||||
True
|
||||
Bool.true
|
||||
|
||||
## Walks over the string's UTF-8 bytes, calling a function which updates a state using each
|
||||
## UTF-8 `U8` byte as well as the index of that byte within the string.
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
when Delmin (Del rx) 0 is
|
||||
Delmin (Del ry ) _ -> Node Black 0 False ry
|
||||
Delmin (Del ry ) _ -> Node Black 0 Bool.false ry
|
||||
|
|
|
@ -1 +1 @@
|
|||
1 * if True then 1 else 1
|
||||
1 * if Bool.true then 1 else 1
|
||||
|
|
|
@ -1 +1 @@
|
|||
{x : if True then 1 else 2, y: 3 }
|
||||
{x : if Bool.true then 1 else 2, y: 3 }
|
|
@ -131,19 +131,19 @@ encodeCharacters = \a, b, c, d ->
|
|||
isValidChar : U8 -> Bool
|
||||
isValidChar = \c ->
|
||||
if isAlphaNum c then
|
||||
True
|
||||
Bool.true
|
||||
else
|
||||
when c is
|
||||
43 ->
|
||||
# '+'
|
||||
True
|
||||
Bool.true
|
||||
|
||||
47 ->
|
||||
# '/'
|
||||
True
|
||||
Bool.true
|
||||
|
||||
_ ->
|
||||
False
|
||||
Bool.false
|
||||
|
||||
isAlphaNum : U8 -> Bool
|
||||
isAlphaNum = \key ->
|
||||
|
|
|
@ -5,7 +5,7 @@ app "issue2279"
|
|||
|
||||
main =
|
||||
text =
|
||||
if True then
|
||||
if Bool.true then
|
||||
Issue2279Help.text
|
||||
else
|
||||
Issue2279Help.asText 42
|
||||
|
|
|
@ -28,7 +28,7 @@ lengthHelp = \foobar, acc ->
|
|||
safe : I64, I64, ConsList I64 -> Bool
|
||||
safe = \queen, diagonal, xs ->
|
||||
when xs is
|
||||
Nil -> True
|
||||
Nil -> Bool.true
|
||||
Cons q t ->
|
||||
queen != q && queen != q + diagonal && queen != q - diagonal && safe queen (diagonal + 1) t
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@ setBlack = \tree ->
|
|||
isRed : Tree a b -> Bool
|
||||
isRed = \tree ->
|
||||
when tree is
|
||||
Node Red _ _ _ _ -> True
|
||||
_ -> False
|
||||
Node Red _ _ _ _ -> Bool.true
|
||||
_ -> Bool.false
|
||||
|
||||
lt = \x, y -> x < y
|
||||
|
||||
|
|
|
@ -74,8 +74,8 @@ setBlack = \tree ->
|
|||
isRed : Tree a b -> Bool
|
||||
isRed = \tree ->
|
||||
when tree is
|
||||
Node Red _ _ _ _ -> True
|
||||
_ -> False
|
||||
Node Red _ _ _ _ -> Bool.true
|
||||
_ -> Bool.false
|
||||
|
||||
ins : Tree I64 Bool, I64, Bool -> Tree I64 Bool
|
||||
ins = \tree, kx, vx ->
|
||||
|
@ -93,13 +93,13 @@ ins = \tree, kx, vx ->
|
|||
when Num.compare kx ky is
|
||||
LT ->
|
||||
when isRed a is
|
||||
True -> balanceLeft (ins a kx vx) ky vy b
|
||||
False -> Node Black (ins a kx vx) ky vy b
|
||||
Bool.true -> balanceLeft (ins a kx vx) ky vy b
|
||||
Bool.false -> Node Black (ins a kx vx) ky vy b
|
||||
|
||||
GT ->
|
||||
when isRed b is
|
||||
True -> balanceRight a ky vy (ins b kx vx)
|
||||
False -> Node Black a ky vy (ins b kx vx)
|
||||
Bool.true -> balanceRight a ky vy (ins b kx vx)
|
||||
Bool.false -> Node Black a ky vy (ins b kx vx)
|
||||
|
||||
EQ ->
|
||||
Node Black a kx vx b
|
||||
|
@ -137,8 +137,8 @@ balanceRight = \l, k, v, r ->
|
|||
isBlack : Color -> Bool
|
||||
isBlack = \c ->
|
||||
when c is
|
||||
Black -> True
|
||||
Red -> False
|
||||
Black -> Bool.true
|
||||
Red -> Bool.false
|
||||
|
||||
Del a b : [Del (Tree a b) Bool]
|
||||
|
||||
|
@ -155,10 +155,10 @@ makeBlack : Map -> Del I64 Bool
|
|||
makeBlack = \t ->
|
||||
when t is
|
||||
Node Red l k v r ->
|
||||
Del (Node Black l k v r) False
|
||||
Del (Node Black l k v r) Bool.false
|
||||
|
||||
_ ->
|
||||
Del t True
|
||||
Del t Bool.true
|
||||
|
||||
rebalanceLeft = \c, l, k, v, r ->
|
||||
when l is
|
||||
|
@ -166,7 +166,7 @@ rebalanceLeft = \c, l, k, v, r ->
|
|||
Del (balanceLeft (setRed l) k v r) (isBlack c)
|
||||
|
||||
Node Red lx kx vx rx ->
|
||||
Del (Node Black lx kx vx (balanceLeft (setRed rx) k v r)) False
|
||||
Del (Node Black lx kx vx (balanceLeft (setRed rx) k v r)) Bool.false
|
||||
|
||||
_ ->
|
||||
boom "unreachable"
|
||||
|
@ -177,7 +177,7 @@ rebalanceRight = \c, l, k, v, r ->
|
|||
Del (balanceRight l k v (setRed r)) (isBlack c)
|
||||
|
||||
Node Red lx kx vx rx ->
|
||||
Del (Node Black (balanceRight l k v (setRed lx)) kx vx rx) False
|
||||
Del (Node Black (balanceRight l k v (setRed lx)) kx vx rx) Bool.false
|
||||
|
||||
_ ->
|
||||
boom "unreachable"
|
||||
|
@ -187,24 +187,24 @@ delMin = \t ->
|
|||
Node Black Leaf k v r ->
|
||||
when r is
|
||||
Leaf ->
|
||||
Delmin (Del Leaf True) k v
|
||||
Delmin (Del Leaf Bool.true) k v
|
||||
|
||||
_ ->
|
||||
Delmin (Del (setBlack r) False) k v
|
||||
Delmin (Del (setBlack r) Bool.false) k v
|
||||
|
||||
Node Red Leaf k v r ->
|
||||
Delmin (Del r False) k v
|
||||
Delmin (Del r Bool.false) k v
|
||||
|
||||
Node c l k v r ->
|
||||
when delMin l is
|
||||
Delmin (Del lx True) kx vx ->
|
||||
Delmin (Del lx Bool.true) kx vx ->
|
||||
Delmin (rebalanceRight c lx k v r) kx vx
|
||||
|
||||
Delmin (Del lx False) kx vx ->
|
||||
Delmin (Del (Node c lx k v r) False) kx vx
|
||||
Delmin (Del lx Bool.false) kx vx ->
|
||||
Delmin (Del (Node c lx k v r) Bool.false) kx vx
|
||||
|
||||
Leaf ->
|
||||
Delmin (Del t False) 0 False
|
||||
Delmin (Del t Bool.false) 0 Bool.false
|
||||
|
||||
delete : Tree I64 Bool, I64 -> Tree I64 Bool
|
||||
delete = \t, k ->
|
||||
|
@ -216,32 +216,32 @@ del : Tree I64 Bool, I64 -> Del I64 Bool
|
|||
del = \t, k ->
|
||||
when t is
|
||||
Leaf ->
|
||||
Del Leaf False
|
||||
Del Leaf Bool.false
|
||||
|
||||
Node cx lx kx vx rx ->
|
||||
if (k < kx) then
|
||||
when del lx k is
|
||||
Del ly True ->
|
||||
Del ly Bool.true ->
|
||||
rebalanceRight cx ly kx vx rx
|
||||
|
||||
Del ly False ->
|
||||
Del (Node cx ly kx vx rx) False
|
||||
Del ly Bool.false ->
|
||||
Del (Node cx ly kx vx rx) Bool.false
|
||||
else if (k > kx) then
|
||||
when del rx k is
|
||||
Del ry True ->
|
||||
Del ry Bool.true ->
|
||||
rebalanceLeft cx lx kx vx ry
|
||||
|
||||
Del ry False ->
|
||||
Del (Node cx lx kx vx ry) False
|
||||
Del ry Bool.false ->
|
||||
Del (Node cx lx kx vx ry) Bool.false
|
||||
else
|
||||
when rx is
|
||||
Leaf ->
|
||||
if isBlack cx then makeBlack lx else Del lx False
|
||||
if isBlack cx then makeBlack lx else Del lx Bool.false
|
||||
|
||||
Node _ _ _ _ _ ->
|
||||
when delMin rx is
|
||||
Delmin (Del ry True) ky vy ->
|
||||
Delmin (Del ry Bool.true) ky vy ->
|
||||
rebalanceLeft cx lx ky vy ry
|
||||
|
||||
Delmin (Del ry False) ky vy ->
|
||||
Del (Node cx lx ky vy ry) False
|
||||
Delmin (Del ry Bool.false) ky vy ->
|
||||
Del (Node cx lx ky vy ry) Bool.false
|
||||
|
|
|
@ -18,8 +18,8 @@ main =
|
|||
showBool : Bool -> Str
|
||||
showBool = \b ->
|
||||
when b is
|
||||
True -> "True"
|
||||
False -> "False"
|
||||
Bool.true -> "true"
|
||||
Bool.talse -> "false"
|
||||
|
||||
test1 : Bool
|
||||
test1 =
|
||||
|
|
|
@ -67,12 +67,12 @@ getInt =
|
|||
Effect.getInt
|
||||
\{ isError, value } ->
|
||||
when isError is
|
||||
True ->
|
||||
Bool.true ->
|
||||
# when errorCode is
|
||||
# # A -> Task.fail InvalidCharacter
|
||||
# # B -> Task.fail IOError
|
||||
# _ ->
|
||||
Task.succeed -1
|
||||
|
||||
False ->
|
||||
Bool.false ->
|
||||
Task.succeed value
|
||||
|
|
|
@ -104,4 +104,4 @@ inWhileScope = \ctx ->
|
|||
scope.whileInfo != None
|
||||
|
||||
Err ListWasEmpty ->
|
||||
False
|
||||
Bool.false
|
||||
|
|
|
@ -16,7 +16,7 @@ interface Path
|
|||
## You can canonicalize a [Path] using [Path.canonicalize].
|
||||
##
|
||||
## Comparing canonical paths is often more reliable than comparing raw ones.
|
||||
## For example, `Path.fromStr "foo/bar/../baz" == Path.fromStr "foo/baz"` will return `False`,
|
||||
## For example, `Path.fromStr "foo/bar/../baz" == Path.fromStr "foo/baz"` will return `Bool.false`,
|
||||
## because those are different paths even though their canonical equivalents would be equal.
|
||||
##
|
||||
## Also note that canonicalization reads from the file system (in order to resolve symbolic
|
||||
|
@ -233,7 +233,7 @@ WindowsRoot : []
|
|||
# Str.concat prefixStr suffixStr
|
||||
# |> FromStr
|
||||
# InternalPath.wrap content
|
||||
## Returns `True` if the first path begins with the second.
|
||||
## Returns `Bool.true` if the first path begins with the second.
|
||||
# startsWith : Path, Path -> Bool
|
||||
# startsWith = \path, prefix ->
|
||||
# when InternalPath.unwrap path is
|
||||
|
@ -249,14 +249,14 @@ WindowsRoot : []
|
|||
# # Compare the two for equality.
|
||||
# Str.isEqUtf8 prefixStr bytesPrefix
|
||||
# else
|
||||
# False
|
||||
# Bool.false
|
||||
# FromStr pathStr ->
|
||||
# when InternalPath.unwrap prefix is
|
||||
# FromOperatingSystem prefixBytes | ArbitraryBytes prefixBytes ->
|
||||
# Str.startsWithUtf8 pathStr prefixBytes
|
||||
# FromStr prefixStr ->
|
||||
# Str.startsWith pathStr prefixStr
|
||||
## Returns `True` if the first path ends with the second.
|
||||
## Returns `Bool.true` if the first path ends with the second.
|
||||
# endsWith : Path, Path -> Bool
|
||||
# endsWith = \path, prefix ->
|
||||
# when InternalPath.unwrap path is
|
||||
|
@ -272,7 +272,7 @@ WindowsRoot : []
|
|||
# # Compare the two for equality.
|
||||
# Str.startsWithUtf8 suffixStr bytesSuffix
|
||||
# else
|
||||
# False
|
||||
# Bool.false
|
||||
# FromStr pathStr ->
|
||||
# when InternalPath.unwrap suffix is
|
||||
# FromOperatingSystem suffixBytes | ArbitraryBytes suffixBytes ->
|
||||
|
|
|
@ -152,7 +152,7 @@ appendHelp = \prefix, suffix ->
|
|||
Err NotFound ->
|
||||
# This should never happen, because we already verified
|
||||
# that the suffix startsWith "/"
|
||||
# TODO `expect False` here with a comment
|
||||
# TODO `expect Bool.false` here with a comment
|
||||
Str.concat prefix suffix
|
||||
else
|
||||
# prefix ends with "/" but suffix doesn't start with one, so just append.
|
||||
|
@ -334,15 +334,15 @@ query = \@Url urlStr ->
|
|||
Ok { after } -> after
|
||||
Err NotFound -> ""
|
||||
|
||||
## Returns `True` if the URL has a `?` in it.
|
||||
## Returns `Bool.true` if the URL has a `?` in it.
|
||||
##
|
||||
## Url.fromStr "https://example.com?key=value#stuff"
|
||||
## |> Url.hasQuery
|
||||
## # True
|
||||
## # Bool.true
|
||||
##
|
||||
## Url.fromStr "https://example.com#stuff"
|
||||
## |> Url.hasQuery
|
||||
## # False
|
||||
## # Bool.false
|
||||
hasQuery : Url -> Bool
|
||||
hasQuery = \@Url urlStr ->
|
||||
# TODO use Str.contains once it exists. It should have a "fast path"
|
||||
|
@ -404,15 +404,15 @@ withFragment = \@Url urlStr, fragmentStr ->
|
|||
# The URL didn't have a fragment, so give it this one
|
||||
@Url "\(urlStr)#\(fragmentStr)"
|
||||
|
||||
## Returns `True` if the URL has a `#` in it.
|
||||
## Returns `Bool.true` if the URL has a `#` in it.
|
||||
##
|
||||
## Url.fromStr "https://example.com?key=value#stuff"
|
||||
## |> Url.hasFragment
|
||||
## # True
|
||||
## # Bool.true
|
||||
##
|
||||
## Url.fromStr "https://example.com?key=value"
|
||||
## |> Url.hasFragment
|
||||
## # False
|
||||
## # Bool.false
|
||||
hasFragment : Url -> Bool
|
||||
hasFragment = \@Url urlStr ->
|
||||
# TODO use Str.contains once it exists. It should have a "fast path"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue