StateT's catchError discards changes to state
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 28/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Lĩnh vực
- documentation
Hướng nghiên cứu
The issue identifies the StateT documentation as the place to explain this behavior, but names no documentation file or test. Start by locating the StateT documentation and reviewing its existing description of catchError. Done means the docs explain that state changes made before an error are discarded in this transformer stack.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
StateT's catchError doesn't take into account that the state can change in the call to is first parameter:
instance monadErrorStateT :: MonadError e m => MonadError e (StateT s m) where
catchError (StateT m) h =
StateT \s -> catchError (m s) (\e -> case h e of StateT f -> f s)
StateT's function m COULD change state and if it does, that state change is lost, i.e. it's neither captured nor is it passed to f.
This is ONLY noticeable when you have a Stack where StateT is ABOVE ExceptT otherwise StateT's catchError will NOT be called.
After many tests, I've come to the conclusion that this CANNOT be fixed. Here was my initial attempt to fix it:
instance monadErrorStateT :: MonadError e m => MonadError e (StateT s m) where
catchError (StateT m) h =
StateT \s -> m s >>= \t@(Tuple _ s') -> catchError (pure t) (\e -> case h e of StateT f -> f s')
The problem is that ExceptT is BELOW StateT in the Stack. That means that m s >>= ... will Short-circuit, which is NOT the desired behavior here.
I cannot see any way to capture the changes made to the state by the first call that won't Short-circuit.
So, the only question that remains is how to communicate this information in the docs. The only place that makes sense in the StateT docs.
- Ngôn ngữ chính
- PureScript
- Star
- 72
- Fork
- 43
- Merge trung bình
- 2 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không 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 purescript/purescript-transformers
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 52/100
-
MonadAsk is over constrainedĐang mởtype: breaking change
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
purescript/purescript-transformers#144 · 2 bình luận ·
-
type: enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 18/100
purescript/purescript-transformers#123 · 4 bình luận ·
-
maybeToExceptTĐang mởtype: enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 42/100
-
type: documentation
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
purescript/purescript-transformers#117 · 6 bình luận ·
Tất cả issue của purescript/purescript-transformers
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
kubescape/node-agent#1099 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[workshop-sim] Improve: Provide a concrete example and activity checks in agentic intro (step 5)Đang mởfeedback simulation workshop
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
githubnext/gh-aw-workshop#5715 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
README Quick Start query command fails, and doctor points to a missing Prerequisites sectionĐang mởdocumentation type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area-multi-tenancy p1-recommended technical-debt
Độ 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
-
Docs: 2 broken linksĐang mởBug pulumi/pulumi-terraform-bridge R2 S2
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
pulumi/pulumi-terraform-bridge#3713 ·
Maintainer thường phản hồi trong vòng 1 ngày