Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Traverse Lens Documentation Needs more Examples

Đang mở
#533 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tài liệu
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
fsharp
Lĩnh vực
documentation

Hướng nghiên cứu

Bắt đầu với tài liệu về lens và các unit test được tham chiếu trong issue, sử dụng ví dụ tuple F# được cung cấp làm trường hợp tái hiện nhỏ nhất. Tài liệu hóa các ví dụ cho thấy List.traverse có kiểu so với traverse đa hình, đồng thời giải thích rằng items là bí danh của traverse. Hoàn thành khi tài liệu và các test minh họa làm rõ sự khác biệt đối với các model Record hoặc Tuple.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Description

The documentation around using a lens to update a collection type within a Record or other data structure could be clearer.

Repro steps
  1. Install FSharpPlus and try to run the code below:
#r "nuget: FSharpPlus"

open FSharpPlus
open FSharpPlus.Lens
open FSharpPlus.Data

let data = (1, ["a";"b";"c"])
// Simple working example
let result1 = over (_2 << List.traverse) String.toUpper data
// The first thing one might try based on the documentation only to be greeted with
// mystifying compiler error
let result2 = over (_2 << traverse) String.toUpper data
Expected behavior

Documentation should remind the user that when trying to use items or traverse as part of a lens function composition, they should reference the typed version of traverse that matches their data structure. It would also be helpful to note that items is just an alias of traverse.

Actual behavior

All documentation examples use the polymorphic traverse function. Even the unit tests barely provide a decent example since the one example use of traverse is with nested lists in lists. I would image that most real world use of traverse would involve a Record or Tuple as the top level Model object (good old Elmish) and if one is just skimming through the tests trying to learn about lenses, they might not make the connection.

Known workarounds

Bang your head against the compiler until you gain insight.

Related information
  • Windows 10 / WSL Ubuntiu
  • .CoreCLR 6.0
Next Steps

I do not mind creating a PR to update the docs and add some more tests that are basically just examples more so than anything that covers a special corner case. Just let me know if the team is interested in making the changes and I will do the work.

Ngôn ngữ chính
F#
Star
942
Fork
106
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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của fsprojects/FSharpPlus

Tất cả issue của fsprojects/FSharpPlus

Issue tương tự

Thêm issue về Documentation

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.