StateT's catchError discards changes to state
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 1/5
- Tempo estimado
- Menos de uma hora
- Facilidade para iniciantes
- 28/100
- Tipo de issue
- Documentação
- Clareza
- Claramente especificada
- Status de atividade
- Estagnada
- Domínio
- documentation
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- PureScript
- Estrelas
- 72
- Forks
- 43
- Merge médio
- 2d 23h
- PRs com merge (30d)
- 1
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Sem guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de purescript/purescript-transformers
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 52/100
-
MonadAsk is over constrainedAbertatype: breaking change
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
purescript/purescript-transformers#144 · 2 comentários ·
-
type: enhancement
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 18/100
purescript/purescript-transformers#123 · 4 comentários ·
-
maybeToExceptTAbertatype: enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 42/100
-
type: documentation
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 30/100
purescript/purescript-transformers#117 · 6 comentários ·
Todas as issues de purescript/purescript-transformers
Issues semelhantes
-
bug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 75/100
MetrolistGroup/Metrolist#4554 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
kubescape/node-agent#1099 ·
Mantenedores costumam responder em até 1 dia
-
15.0
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
-
[workshop-sim] Improve: Provide a concrete example and activity checks in agentic intro (step 5)Abertafeedback simulation workshop
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
githubnext/gh-aw-workshop#5715 ·
Mantenedores costumam responder em até 1 dia