Commit Graph

757 Commits

Author SHA1 Message Date
ayazhafiz
fe99d20be5 Apply review suggestions 2021-11-18 21:49:37 -05:00
ayazhafiz
5bfc52cd3b Remove Sugar enum and inline single variant into CalledVia 2021-11-18 21:23:41 -05:00
ayazhafiz
8b7217847d Rename additional stale roc_module::operator refs and format 2021-11-18 20:20:33 -05:00
ayazhafiz
8a60162a1e Rename roc_module::operator -> roc_module::called_via
A bit of a nit, but this file is now more general than just keeping
track of operator methods.
2021-11-18 20:20:33 -05:00
ayazhafiz
30955a1eb8 Take syntactic sugar into account when reporting errors
Previously, a program like

```roc
word = "word"

if True then 1 else "\(word) is a word"
```

would report an error like

```
── TYPE MISMATCH ───────────────────────────────────────────────────────────────

This `if` has an `else` branch with a different type from its `then` branch:

3│  if True then 1 else "\(word) is a word"
                        ^^^^^^^^^^^^^^^^^^

This concat all produces:

    Str

but the `then` branch has the type:

    Num a

I need all branches in an `if` to have the same type!
```

but this is a little bit confusing, since the user shouldn't have to
know (or care) that string interpolations are equivalent to
concatenations under the current implementation.

Indeed we should make this fully transparent. We now word the error
message by taking into account the way calls are made. To support the
case shown above, we introduce the `CalledVia::Sugar` variant to
represent the fact that some calls may be the result of desugaring the
surface syntax.

This commit also demonstrates the usage of `CalledVia` to produce better
error messages where we use binary comparison operators like `<`. There
are more improvements we can make here for all `CalledVia` variants, but
this is a good starting point to demonstrate the usage of the new
procedure.

Closes #1714
2021-11-18 20:20:33 -05:00
Michael Downey
d11bb93539
Merge branch 'trunk' into add_list_all 2021-11-18 16:09:24 -05:00
Michael Downey
9d587d37b4
Merge branch 'trunk' into add_list_all 2021-11-18 06:41:08 -05:00
satotake
9aabd08953 fmt 2021-11-18 11:17:05 +00:00
satotake
ce8a88416d Merge branch 'trunk' into builtins-list-intersperse 2021-11-18 11:16:27 +00:00
satotake
7ce9f1b3bd refactor after review 2021-11-18 10:15:38 +00:00
ayazhafiz
214b8a30a9 Suggest typo fixes for non-existing module values 2021-11-17 22:40:51 -05:00
Joshua Warner
7f5b873357 Parse _ in type annotations as an 'Inferred' type 2021-11-17 17:59:40 -08:00
Richard Feldman
2bb007e08b
Merge pull request #1987 from rtfeldman/builtins-list-split
Add builtin `List.split`
2021-11-17 13:41:58 -05:00
satotake
16fb04b4fa Add builtin List.intersperse 2021-11-17 15:18:45 +00:00
Michael Downey
d946b84e63 adding initial List.all 2021-11-16 16:34:36 -05:00
satotake
46e6e22776 use closure 2021-11-16 12:58:45 +00:00
satotake
541465bc2e Use let 2021-11-16 11:13:37 +00:00
satotake
73dda714de Add builtin List.split 2021-11-15 13:50:11 +00:00
satotake
c253273490 Merge branch 'trunk' into refactor-builtin-list-drop 2021-11-15 11:37:32 +00:00
satotake
5b64eb6983 refacotr List.drop 2021-11-14 13:46:40 +00:00
Folkert de Vries
28eb7a03cc
Merge branch 'trunk' into joshuawarner32/use-collection-4 2021-11-14 13:40:51 +01:00
Joshua Warner
9bf1674946 Shrink Collection to make parse_expr_size test pass 2021-11-13 16:17:44 -08:00
Theo Felippe
8d7c252fce implemented Str.trimRight 2021-11-13 18:02:58 +00:00
Joshua Warner
1fabc64fdf Use Collection in Expr::TagUnion 2021-11-13 07:38:39 -08:00
Joshua Warner
d63405d824 Make Expr::List use a Collection 2021-11-13 07:38:11 -08:00
Joshua Warner
a4ca6a31a6 Use Collection in Expr::Record and related places 2021-11-13 07:36:05 -08:00
Folkert de Vries
c9b15766be
Merge branch 'trunk' into builtins-refactor-list-take 2021-11-13 13:29:57 +01:00
Theo Felippe
10eab4b785 implemented Result.isErr 2021-11-13 08:29:40 +00:00
satotake
9ec2bc7946 Remove takeFirst and takeLast from backend 2021-11-13 06:03:18 +00:00
satotake
2e073d57ea destruct record at high level 2021-11-13 05:13:46 +00:00
satotake
98d2c57edf move List.sublist to backend 2021-11-13 04:57:28 +00:00
satotake
8f8b2463ea reset 2021-11-13 03:38:58 +00:00
satotake
4359dcff73 Merge branch 'trunk' into builtins-refactor-list-take 2021-11-13 03:38:29 +00:00
satotake
a9216d1149 retry recursion 2021-11-13 02:57:45 +00:00
satotake
d63849c5a3 Add List.takeFisrt2, List.takeLast2 for demo 2021-11-12 13:47:28 +00:00
Theo Felippe
356e36b38a Merge branch 'trunk' into builtin-result-is-ok 2021-11-12 10:13:43 +00:00
Theo Felippe
cb9ec369fe working implementation 2021-11-12 10:08:39 +00:00
Joshua Warner
04d4a8ca79 Introduce Collection as a general abstraction in the ast 2021-11-11 14:49:33 -08:00
Theo Felippe
84af26d813 added placeholder implementation 2021-11-11 19:13:42 +00:00
Folkert
33e8f9a6b7 Merge remote-tracking branch 'origin/trunk' into cleanup-im-dependency 2021-11-10 17:19:54 +01:00
Folkert de Vries
b3a663a741
Merge branch 'trunk' into builtins-list-sublist 2021-11-10 16:28:58 +01:00
Folkert
5632e3159d remove im dependency where not needed 2021-11-10 16:00:22 +01:00
satotake
9f5d3f521b Implement List.sublist 2021-11-10 13:16:57 +00:00
Michael Downey
07cd3850d7
Merge branch 'trunk' into str_trim_left 2021-11-09 19:43:26 -05:00
Michael Downey
7e074d300e cleaning up and adding comments 2021-11-09 14:37:31 -05:00
Michael Downey
1bc278d962 initial commit of Str.trimLeft 2021-11-09 14:25:24 -05:00
Folkert
94efbd0e95 Merge remote-tracking branch 'origin/trunk' into builtins-list-take-last 2021-11-09 16:18:19 +01:00
satotake
772fc9c021 Implement List.takeLast 2021-11-09 12:26:17 +00:00
ayazhafiz
074c2ca398 Remove stale DICT_TEST_HASH reference 2021-11-08 21:04:59 -05:00
ayazhafiz
f65b174ab5 Implement List.find
`List.find : List elem, (elem -> Bool) -> Result elem [ NotFound ]*`
behaves as follows:

```
>>> List.find [1, 2, 3] (\n -> n > 2)
Ok 2
>>> List.find [1, 2, 3] (\n -> n > 4)
Err NotFound
```

We implement this as builtin in two phases. First, we call out to a
pure-llvm-lowlevel `ListFindUnsafe` that returns a record indicating
whether a satisfying element was found, and the value of that element
(the value is all null bytes if the element wasn't found). Then, we lift
that record to a `Result` via a standard construction of the can AST.

Closes #1909
2021-11-08 21:03:14 -05:00
satotake
9087bf7273 Merge branch 'trunk' into builtsins-list-take-first 2021-11-08 14:32:36 +00:00
satotake
878400f95f Implement List.takeFirst 2021-11-08 14:10:53 +00:00
satotake
97c82d8d51 pick 02acef6 2021-11-08 11:15:20 +00:00
Kevin Sjöberg
44938a9e35 Implement List.any 2021-11-07 20:44:10 +01:00
ayazhafiz
0d2ed76334 Implement List.joinMap
Closes #1887
2021-11-07 11:08:20 -05:00
Brendan Hansknecht
73e2cbcb1e Make versions numbers consistent and matching the lock files 2021-11-06 13:24:45 -07:00
Anton-4
69f6ffadab
Merge branch 'trunk' into deps 2021-11-06 18:07:34 +01:00
Kevin Sjöberg
f6d055dc62 Correct minor spelling mistakes 2021-11-06 15:29:08 +01:00
Richard Feldman
3df3e2f0d5
Merge branch 'trunk' into deps 2021-11-06 07:19:02 -04:00
Chelsea Troy
208bce563a
Merge branch 'trunk' into dropfirst-builtin 2021-11-05 23:34:46 -05:00
Brendan Hansknecht
d49ac68bcc Update dep with major version changes 2021-11-05 19:19:37 -07:00
Brendan Hansknecht
bddc08c977 Remove unused dependencies 2021-11-05 16:58:11 -07:00
Eric Newbury
f3a350dd74 add dropFirst builtin 2021-11-05 16:12:29 -04:00
Folkert
c5005d3dd1 Merge remote-tracking branch 'origin/trunk' into partialproc-by-reference 2021-11-03 15:32:39 +01:00
Folkert
bc71cf53d6 simplify capturing closure IR gen 2021-11-03 14:26:14 +01:00
Folkert
a15183a7d1 refactor 2021-11-03 14:09:04 +01:00
Anton-4
a3fc724df3 removed unused maplit 2021-11-03 10:50:25 +01:00
Kevin Sjöberg
3fbb081f75 Correct comment of List.map3 signature 2021-10-31 21:08:41 +01:00
Kevin Sjöberg
f9ed060e49 Implement List.map4 2021-10-31 21:08:41 +01:00
Chelsea Troy
4afaf96aea
Add List.max builtin 2021-10-30 19:17:35 -05:00
Folkert de Vries
aa978ae6d9
Merge branch 'trunk' into list_min 2021-10-28 20:32:27 +02:00
Tim Whiting
329c035e24 fix comment 2021-10-27 20:31:07 -06:00
Tim Whiting
c721a1cc1f add builtin List.min 2021-10-27 20:28:34 -06:00
Folkert de Vries
29bd4e3e50
Merge branch 'trunk' into str_trim 2021-10-26 22:45:32 +02:00
Dan Knutson
7ed37bf544 use lowlevel_n helper 2021-10-25 20:22:37 -05:00
Dan Knutson
e1b9699272 remove TODO tags 2021-10-25 20:22:37 -05:00
Dan Knutson
e7523ad41d add Roc wiring 2021-10-25 20:22:37 -05:00
Chelsea Troy
789cc5acc0
cargo fmt 2021-10-25 00:28:50 -05:00
Chelsea Troy
063d7b178b
Figured out why dropLast call was producing an argument mismatch:
- Although list_drop_last's LowLevel operation modeling (body) was correct, the defn() CALLED that body with an extra argument for index (a copy-paste error from dropAt).
- List.dropAt works now :)
2021-10-25 00:06:37 -05:00
Chelsea Troy
9633a5adaa
Fix the build, but List.dropLast itself still doesn't work. 2021-10-23 00:29:13 -05:00
Chelsea Troy
fd83c3b749
Branch the dropLast functionality from dropAt, inserting an index gathered by subtracting 1 from the list length 2021-10-23 00:17:08 -05:00
Folkert
4152519bfb formatting & catch zig overflow error 2021-10-17 18:03:40 +02:00
Chelsea Troy
0cc6e44d35
Thread through the divCeil implementation from Zig:
+ OPEN QUESTION: Evidently the Zig implementation can throw an overflow error. Do we want to do something in Roc to fix this?
2021-10-17 10:46:16 -05:00
Richard Feldman
a0887da6ca
Merge pull request #1645 from rtfeldman/list-walk-flip
Reorder List.walk arguments
2021-10-10 08:38:20 -04:00
Folkert
94e8c62613 make things compile, base64 has a memory leak 2021-10-06 22:57:11 +02:00
Richard Feldman
90401477c9 Fix List.walkUntil arg order 2021-10-06 07:32:56 -04:00
Richard Feldman
8391c337ab Merge remote-tracking branch 'origin/trunk' into list-walk-flip 2021-10-05 20:50:50 -04:00
Anton-4
ab665b7380 Merge branch 'trunk' of github.com:rtfeldman/roc into docs_markup 2021-10-05 11:58:45 +02:00
Dan Knutson
3baff93a97 add first version of List.dropAt
* adds an implementation with no uniqueness/mutability
2021-10-03 13:55:11 -05:00
Anton-4
f63c276a5f docs flow working with mocked markup to html 2021-10-01 18:22:27 +02:00
Kofi Gumbs
b32a42f05a Add Str.repeat builtin 2021-09-29 17:32:42 -04:00
Folkert
b257a24edf don't canonicalize Apply arguments twice 2021-09-22 21:16:40 +02:00
Richard Feldman
71a678c092 Update Dict.walk to match List.walk 2021-08-30 23:05:15 -04:00
Richard Feldman
1abebb7713 Reorder args for List.walk and friends 2021-08-30 22:45:10 -04:00
Folkert
1ca0b797ea make Dict.len return a nat 2021-08-29 23:04:20 +02:00
Folkert
de7db3e730 make more things infer as NAT 2021-08-29 13:31:55 +02:00
Jared Ramirez
ced4307b46 Fix can tests 2021-08-26 11:39:21 -07:00
Jared Ramirez
4b2a63fb30 Merge branch 'trunk' of https://github.com/rtfeldman/roc into store-dec-as-str 2021-08-26 11:23:17 -07:00
Folkert
6a43be26d3 fix usize vs. u32/u64 conflict 2021-08-25 20:58:42 +02:00
Joshua Hoeflich
b57ebb6229 Remove castToNat 2021-08-19 16:11:21 -05:00
Jared Ramirez
d69b9173fc Also store f64 for things like pattern comparisons, etc 2021-08-18 17:18:13 -07:00
Joshua Hoeflich
99feb7ce67 Fix typo in comment 2021-08-18 18:23:19 -05:00
Joshua Hoeflich
2672c8ed10 NumBytesToU16 and NumBytesToU32 tested 2021-08-18 17:39:59 -05:00
Joshua Hoeflich
a4197d073c bytesToU16 and bytesToU32 have proper types 2021-08-18 15:46:53 -05:00
Joshua Hoeflich
b4f575736b castToNat working 2021-08-18 11:31:48 -05:00
Jared Ramirez
adabf70132 [WIP] Update can & pattern to store numbers as validated strs 2021-08-16 16:16:10 -07:00
Joshua Hoeflich
22e781259d TODO: Actually implement the functions 2021-08-14 19:28:13 -05:00
Joshua Hoeflich
9dad304e95 Passing arguments successfully to bytesToU16 2021-08-14 19:11:27 -05:00
Joshua Hoeflich
c8f6762deb Switch from floats to usize 2021-08-14 18:30:43 -05:00
Joshua Hoeflich
744fefc3a1 Fixed: Actually calling llvm we generate 2021-08-14 18:20:11 -05:00
Joshua Hoeflich
ff2c3d7945 Dummy implementation that doesn't do what we want 2021-08-14 17:59:53 -05:00
Folkert
24ddc4b1e8 further optimizations 2021-08-13 13:25:36 +02:00
Folkert
df83bf0d48 Merge remote-tracking branch 'origin/soa-alias' into alias-nominal-equality 2021-08-13 12:11:36 +02:00
Folkert
574e07807e turn lt into lte 2021-08-11 00:22:15 +02:00
Joshua Hoeflich
29228972c9 Renaming 2021-08-10 10:54:19 -05:00
Joshua Hoeflich
05d87314e7 Consistently triggering null pointer bug 2021-08-10 10:51:15 -05:00
Joshua Hoeflich
ba360a2dd2 Test passing in debug but not release 2021-08-09 22:03:01 -05:00
Joshua Hoeflich
8c13fecc64 Fix name 2021-08-09 20:26:27 -05:00
Joshua Hoeflich
b99a0ae953 Typo fix 2021-08-09 19:51:20 -05:00
Joshua Hoeflich
04f65bed51 Bump comment 2021-08-09 19:31:27 -05:00
Joshua Hoeflich
ae38a0d3ff Cargo fmt 2021-08-08 21:41:00 -05:00
Joshua Hoeflich
c00d400d85 Fixes merge conflict 2021-08-08 21:38:15 -05:00
Joshua Hoeflich
4231b340ee Glue code working 2021-08-08 11:06:10 -05:00
Richard Feldman
2a616103c6 Rename Str.toBytes to Str.toUtf8 2021-08-07 22:46:24 -04:00
Richard Feldman
267836226c s/CodePoint/CodePt/g 2021-08-07 21:46:20 -04:00
Folkert
d4896d3ed2 remove inlinable_string dependency 2021-08-03 21:24:19 +02:00
Folkert
ceb5cc66fa use IdentStr 2021-08-03 21:14:36 +02:00
Richard Feldman
e8fc9c5e4c Thread dep_idents through to LoadedModule 2021-08-01 10:23:16 -04:00
Richard Feldman
5c74bab0ec Persist scope after canonicalizing defs 2021-08-01 10:23:16 -04:00
Folkert
894ef2b7b2 Merge remote-tracking branch 'origin/trunk' into alias-nominal-equality 2021-07-30 23:34:16 +02:00
Folkert
e0648d348d new formatting 2021-07-30 17:13:50 +02:00
Folkert
4f03d2da36 instantiate lambda sets 2021-07-30 15:47:39 +02:00
Folkert
13b05e54e8 Merge remote-tracking branch 'origin/clippy-1.54' into alias-nominal-equality 2021-07-30 14:25:50 +02:00
Folkert
899cbeabd7 fix extra ampersands 2021-07-29 17:32:08 +02:00
Folkert
27c3d57e35 BROKEN 2021-07-29 17:22:25 +02:00
Folkert
aac0e2d9f9 add lambda set vars to host exposed alias 2021-07-29 14:55:10 +02:00
Folkert
4cefbec5c7 store lambda set in alias types 2021-07-28 15:26:25 +02:00
Folkert
2b5ec3dcf1 centralize overflow error reporting 2021-07-18 20:50:15 +02:00
Richard Feldman
53ccef0506 nightly clippy
I was on nightly for benchmarks, and these all seem reasonable.
2021-06-18 15:21:11 -04:00
Folkert
ab7f4a70a1 remove list_var 2021-06-13 16:56:59 +02:00
Folkert
02bc0036ab fix wrong tag name used in Dict.get 2021-06-13 16:54:37 +02:00
Anton-4
22d834ebd9 Merge branch 'trunk' of github.com:rtfeldman/roc into typos_ci 2021-06-07 12:33:26 +02:00
Anton-4
314503cf7f fixed typos, added typos checking to CI 2021-06-05 20:02:54 +02:00
Richard Feldman
1bd3f12776 Fix a bunch of Int docs 2021-06-03 21:31:47 -04:00
tarjei
ade591dd10 Fix plumbing 2021-05-29 22:21:25 +02:00
tarjei
107822a5cc Add plumbing for List.swap 2021-05-29 21:30:16 +02:00
Richard Feldman
75ec2ecc7b
Merge pull request #1300 from rtfeldman/specialize-lowlevel
Polyvariant defunctionalization
2021-05-24 19:54:17 -04:00
Folkert
e81087f913 Merge remote-tracking branch 'origin/trunk' into specialize-lowlevel 2021-05-24 15:17:28 +02:00
Chadtech
ac7386fd27
Merge branch 'trunk' into hash-links 2021-05-24 09:14:52 -04:00
Folkert
fbb711b2ca Merge remote-tracking branch 'origin/trunk' into specialize-lowlevel 2021-05-24 15:11:40 +02:00