StateT's catchError discards changes to state
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 1/5
- Tiempo estimado
- Menos de una hora
- Aptitud para principiantes
- 28/100
- Tipo de issue
- Documentación
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Área
- documentation
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- PureScript
- Estrellas
- 72
- Forks
- 43
- Merge medio
- 2 d 23 h
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de purescript/purescript-transformers
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 52/100
-
MonadAsk is over constrainedAbiertotype: breaking change
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
purescript/purescript-transformers#144 · 2 comentarios ·
-
type: enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 18/100
purescript/purescript-transformers#123 · 4 comentarios ·
-
maybeToExceptTAbiertotype: enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 42/100
-
type: documentation
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
purescript/purescript-transformers#117 · 6 comentarios ·
Todos los issues de purescript/purescript-transformers
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
kubescape/node-agent#1099 ·
Los mantenedores suelen responder en 1 día
-
[workshop-sim] Improve: Provide a concrete example and activity checks in agentic intro (step 5)Abiertofeedback simulation workshop
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
githubnext/gh-aw-workshop#5715 ·
Los mantenedores suelen responder en 1 día
-
README Quick Start query command fails, and doctor points to a missing Prerequisites sectionAbiertodocumentation type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
area-multi-tenancy p1-recommended technical-debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
Docs: 2 broken linksAbiertoBug pulumi/pulumi-terraform-bridge R2 S2
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
pulumi/pulumi-terraform-bridge#3713 ·
Los mantenedores suelen responder en 1 día