StateT's catchError discards changes to state
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 1/5
- Temps estimé
- Moins d'une heure
- Accessibilité débutants
- 28/100
- Type d'issue
- Documentation
- Clarté
- Clairement spécifiée
- Activité
- À l'abandon
- Domaine
- documentation
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- PureScript
- Étoiles
- 72
- Forks
- 43
- Merge moyen
- 2 j 23 h
- PR mergées (30 j)
- 1
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Aucun guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de purescript/purescript-transformers
-
Difficulté 2/5 1-3 heures Accessibilité débutants 52/100
-
MonadAsk is over constrainedOuvertetype: breaking change
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
purescript/purescript-transformers#144 · 2 commentaires ·
-
type: enhancement
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 18/100
purescript/purescript-transformers#123 · 4 commentaires ·
-
maybeToExceptTOuvertetype: enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 42/100
-
type: documentation
Difficulté 4/5 3-5 jours Accessibilité débutants 30/100
purescript/purescript-transformers#117 · 6 commentaires ·
Toutes les issues de purescript/purescript-transformers
Issues similaires
-
bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 75/100
MetrolistGroup/Metrolist#4554 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
kubescape/node-agent#1099 ·
Les mainteneurs répondent en général sous 1 jour
-
15.0
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
-
[workshop-sim] Improve: Provide a concrete example and activity checks in agentic intro (step 5)Ouvertefeedback simulation workshop
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
githubnext/gh-aw-workshop#5715 ·
Les mainteneurs répondent en général sous 1 jour