StateT's catchError discards changes to state
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 1/5
- Geschätzter Aufwand
- Unter einer Stunde
- Anfängerfreundlichkeit
- 28/100
- Issue-Typ
- Dokumentation
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Bereich
- documentation
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- PureScript
- Sterne
- 72
- Forks
- 43
- Ø Merge
- 2 T. 23 Std.
- Gemergte PRs (30 T.)
- 1
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Kein Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus purescript/purescript-transformers
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 52/100
-
type: breaking change
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
purescript/purescript-transformers#144 · 2 Kommentare ·
-
type: enhancement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 18/100
purescript/purescript-transformers#123 · 4 Kommentare ·
-
maybeToExceptTOffentype: enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 42/100
-
type: documentation
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 30/100
purescript/purescript-transformers#117 · 6 Kommentare ·
Alle Issues in purescript/purescript-transformers
Ähnliche Issues
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 75/100
MetrolistGroup/Metrolist#4554 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
kubescape/node-agent#1099 ·
Maintainer antworten meist innerhalb von 1 Tag
-
15.0
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
-
[workshop-sim] Improve: Provide a concrete example and activity checks in agentic intro (step 5)Offenfeedback simulation workshop
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
githubnext/gh-aw-workshop#5715 ·
Maintainer antworten meist innerhalb von 1 Tag