UTF-8 and text 2.0
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Bắt đầu với hành vi alexGetByte được ghi nhận trong tài liệu và các wrapper hiện có được mô tả trong issue, sau đó so sánh cách chúng xử lý các kiểu Haskell String, ByteString và text 2.0 Text. Làm rõ liệu mục tiêu là các wrapper UTF-8 Text mới hay một interface dựa trên alexGetChar; issue không xác định một triển khai cụ thể hoặc bài kiểm tra hoàn thành.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
As the documentation says, Alex works over a stream of UTF-8 encoded bytes, retrieved one at a time by alexGetByte.
Lexer specifications are written in terms of Unicode characters, but Alex works internally on a UTF-8 encoded byte sequence.
Depending on how you use Alex, the fact that Alex uses UTF-8 encoding internally may or may not affect you. If you use one of the wrappers (below) that takes input from a Haskell String, then the UTF-8 encoding is handled automatically. However, if you take input from a ByteString, then it is your responsibility to ensure that the input is properly UTF-8 encoded.
From an external viewpoint as a consumer (I am not familiar with how Alex is implemented), this seems like a strange design decision to me. If my source is already in a UTF-8 format like String or Data.Text(.Lazy).Text (with the new text 2.0 release), it seems that in order to run Alex on it, I (or a wrapper) would have to write logic to decode the UTF-8 content into individual bytes, just so that Alex can immediately re-encode it back into UTF-8 internally.
So I'm wondering if there's a reason that Alex needs to work over bytes and not Chars, or if that was perhaps done to support lexing ByteStrings directly, without having to first unpack the data into UTF-8 Strings or decode into UTF-16 Texts (with text <2.0), which would be unnecessary overhead either way.
If Alex has to work over bytes for internal reasons, I think it would be a good idea to implement new wrappers for the UTF-8 Text types, since I'd imagine that would be a pretty common use case.
Otherwise, would it be possible to expose an alexGetChar-based interface that simply skips the UTF-8 decoding portion of Alex's internal logic, which would be more ergonomic and efficient for UTF-8 based types?
- Ngôn ngữ chính
- Haskell
- Star
- 323
- Fork
- 87
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của haskell/alex
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
-
Is module DFS really needed?Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Agda-style LexingĐang mởdiscussion
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
haskell/bytestring#730 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
seal-harness/seal-harness#399 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
add previously overlooked rulesĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
fmidue/codeworld-tasks#124 ·
-
allow haskell-src-exts-1.24Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
reflex-frp/reflex#563 ·