Gabriella439 / Gabriella439/turtle
catch catches error in monad continuation
- Dominant language
- Haskell
- Stars
- 978
- Forks
- 94
- PR merge metrics
- No merged PRs in 30d
Description
I have the following code
```haskell
prog1 :: Shell ()
prog1 = do
echo "prog1"
catch
( do
echo "will be catched"
pure ())
(\(_ :: SomeException) -> do
echo "exception")
prog2 :: IO ()
prog2 = do
echo "prog2"
procs "lll" [] mempty
mainMenu' :: Shell ()
mainMenu' = do
echo "mainMenu"
prog1
liftIO prog2
```
I would expect that running this will not run the error handler (it will not print "exception). But runnig it prints it
```haskell
*Main> sh $ mainMenu'
mainMenu
prog1
will be catched
prog2
exception
prog2
*** Exception: lll: createProcess: posix_spawnp: does not exist (No such file or directory)
```
Doing the same thing in the IO monad works as I expect
I'm on version 1.5.22
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the reported behavior with the `mainMenu'`, `prog1`, and `prog2` example on turtle 1.5.22, then trace how `catch` handles the continuation around `liftIO prog2`. Done means the exception from the missing `lll` process is not handled by the earlier `prog1` catch, while the expected process error behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100