Skip to content

Commit

Permalink
formatting and more explanation for error
Browse files Browse the repository at this point in the history
  • Loading branch information
lucioleKi committed Oct 10, 2024
1 parent 8d40d10 commit 4d26de4
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions eeps/eep-0073.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ EEP 73: Zip generator
Abstract
========

This EEP proposes the addition of zip generators with a syntax of `&&` for
This EEP proposes the addition of zip generators with a syntax of `&&` for
comprehensions in Erlang. The idea and syntax of zip generators (comprehension
multigenerators) was first brought up by EEP-19. Even if the syntax and
usages of zip generators proposed by this EEP is mostly the same with EEP-19,
Expand Down Expand Up @@ -72,11 +72,10 @@ produces a binary, etc.
<<Expression || Qualifier(s)>> %% Binary Comprehension
#{Expression || Qualifier(s)} %% Map Comprehension


Qualifiers can have the following kind: filter, list generator, bitstring
generator, and map generator. Except for filters, the other three kinds of
qualifiers are generators. Their names refer to the type on the right hand
side of `<-` or `<=`. Generators have the following form:
side of `<-` or `<=`. Generators have the following form:

Pattern <- List %% List Generator
Pattern <= Bitstring %% Bitstring Generator
Expand Down Expand Up @@ -138,12 +137,14 @@ Generators of Different Lengths
`lists:zip/2` and `lists:zip3/3` will fail if the given lists are not of the
same length, where `zip/n` will also crash. Therefore, a zip generator raises a
`bad generators` error when it discovers that the given generators are of
different lengths.
different lengths.

When a zip generator crashes because the containing generators are of
different lengths, the error message is a tuple, where the first element
is the atom `bad_generators`, and the second element is a tuple that contains
the remaining data from all generators.
different lengths, the internal error message is a tuple, where the first
element is the atom `bad_generators`, and the second element is a tuple that
contains the remaining data from all generators. The user-facing error message
is `bad generators: `, followed by the tuple containing remaining data from

Check failure on line 146 in eeps/eep-0073.md

View workflow job for this annotation

GitHub Actions / markdownlint

Spaces inside code span elements

eeps/eep-0073.md:146:4 MD038/no-space-in-code Spaces inside code span elements [Context: "`bad generators: `"] https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md038.md
all generators.

For example, this comprehension will crash at runtime.

Check failure on line 149 in eeps/eep-0073.md

View workflow job for this annotation

GitHub Actions / markdownlint

Trailing spaces

eeps/eep-0073.md:149:55 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md009.md

Expand All @@ -158,7 +159,7 @@ On the compiler's side, it is rather difficult to return the original zip
generator in the error message, or to point out which generator is of
different length comparing to others. The proposed error message aims to
gives the most helpful information without imposing extra burden on the
compiler or runtime.
compiler or runtime.

Non-generator in a Zip Generator
-----------------
Expand All @@ -169,7 +170,7 @@ possible to catch such an error at compile-time, this error is caught by
the Erlang linter.

For example, the zip generator in the following comprehension contains a
non-generator.
filter.

zip() -> [{X,Y} || X <- [1,2,3] && Y <- [1,2,3] && X > 0].

Expand All @@ -180,7 +181,6 @@ allowed in a zip generator, together with the position of the non-generator.
% 6| zip() -> [{X,Y} || X <- [1,2,3] && Y <- [1,2,3] && X > 0].
% | ^


Backwards Compatibility
========================

Expand All @@ -190,7 +190,7 @@ this addition.
Reference Implementation
========================

[Git Branch][1] contains the implementation for zip generators.
[Git Branch][1] contains the implementation for zip generators.

[1]: https://github.com/lucioleKi/otp/tree/isabell/compiler/zip-comprehension/OTP-19184
[2]: https://downloads.haskell.org/~ghc/5.00/docs/set/parallel-list-comprehensions.html
Expand Down

0 comments on commit 4d26de4

Please sign in to comment.