StateT's catchError discards changes to state
还没有人认领这个 Issue。
评估
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 新手友好度
- 28/100
- Issue 类型
- 文档
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- PureScript
- 星标
- 72
- 派生
- 43
- 平均合并
- 2 天 23 小时
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
purescript/purescript-transformers 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 52/100
-
type: breaking change
难度 4/5 3-5 天 新手友好度 35/100
purescript/purescript-transformers#144 · 2 条评论 ·
-
type: enhancement
难度 5/5 一周以上 新手友好度 18/100
purescript/purescript-transformers#123 · 4 条评论 ·
-
maybeToExceptT未关闭type: enhancement
难度 2/5 1-3 小时 新手友好度 42/100
-
type: documentation
难度 4/5 3-5 天 新手友好度 30/100
purescript/purescript-transformers#117 · 6 条评论 ·
查看 purescript/purescript-transformers 的全部 Issue
相似的 Issue
-
bug
难度 1/5 1 小时以内 新手友好度 75/100
MetrolistGroup/Metrolist#4554 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100
kubescape/node-agent#1099 ·
维护者通常 1 天内回复
-
15.0
难度 2/5 1-3 小时 新手友好度 62/100
-
[workshop-sim] Improve: Provide a concrete example and activity checks in agentic intro (step 5)未关闭feedback simulation workshop
难度 2/5 1-3 小时 新手友好度 68/100
githubnext/gh-aw-workshop#5715 ·
维护者通常 1 天内回复