Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a type annotation to List.range #6242

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion crates/compiler/builtins/roc/List.roc
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,13 @@ mapWithIndexHelp = \src, dest, func, index, length ->
## ```
## All of these options are compatible with the others. For example, you can use `At` or `After`
## with `start` regardless of what `end` and `step` are set to.
range : _
range :
{
start : [At (Num a), After (Num a)],
end : [At (Num a), Before (Num a), Length Nat],
step ? Num a,
}*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want the *. I don't think this is a function where it makes sense to accept an open record.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we do, but I thought that was currently necessary because of a bug with optional fields.

At any rate, the main reason I posted this is to reproduce a (different) type checking bug where it says a needs to have an Eq constraint. 😄

-> List (Num a)
range = \{ start, end, step ? 0 } ->
{ calcNext, stepIsPositive } =
if step == 0 then
Expand Down
Loading