Skip to content

Commit

Permalink
Add Sort ability
Browse files Browse the repository at this point in the history
This adds a Sort ability, currently lacking any implementations of the
ability.
  • Loading branch information
jwoudenberg committed May 18, 2024
1 parent f4291f4 commit 10b42f1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/compiler/builtins/roc/List.roc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ module [
walkBackwardsUntil,
countIf,
chunksOf,
Sort,
compare,
]

import Bool exposing [Bool, Eq]
Expand Down Expand Up @@ -1324,3 +1326,6 @@ iterBackwardsHelp = \list, state, f, prevIndex ->
Break b -> Break b
else
Continue state

Sort implements
compare : a, a -> [LessThan, Equal, GreaterThan] where a implements Sort
1 change: 1 addition & 0 deletions crates/compiler/builtins/roc/main.roc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package [
List,
Dict,
Set,
Sort
Decode,
Encode,
Hash,
Expand Down
3 changes: 3 additions & 0 deletions crates/compiler/module/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub const DERIVABLE_ABILITIES: &[(Symbol, &[Symbol])] = &[
(Symbol::DECODE_DECODING, &[Symbol::DECODE_DECODER]),
(Symbol::HASH_HASH_ABILITY, &[Symbol::HASH_HASH]),
(Symbol::BOOL_EQ, &[Symbol::BOOL_IS_EQ]),
(Symbol::LIST_SORT, &[Symbol::LIST_COMPARE]),
(
Symbol::INSPECT_INSPECT_ABILITY,
&[Symbol::INSPECT_TO_INSPECTOR],
Expand Down Expand Up @@ -1531,6 +1532,8 @@ define_builtins! {
86 LIST_WALK_WITH_INDEX_UNTIL: "walkWithIndexUntil"
87 LIST_CLONE: "clone"
88 LIST_LEN_USIZE: "lenUsize"
89 LIST_SORT: "Sort" exposed_type=true
90 LIST_COMPARE: "compare"
}
7 RESULT: "Result" => {
0 RESULT_RESULT: "Result" exposed_type=true // the Result.Result type alias
Expand Down

0 comments on commit 10b42f1

Please sign in to comment.