Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't lose parantheses in show SomeAsyncException #253

Closed
wants to merge 1 commit into from

Conversation

ntc2
Copy link
Contributor

@ntc2 ntc2 commented May 21, 2019

I'd also like to change the string-based show instances in this file so that they wrap the strings with spaces in parens when precedence is 11 or higher, but I worry that change might be controversial. But hopefully this simpler change is not controversial, since we just preserves any existing parens in the wrapped exception.

@ntc2 ntc2 requested a review from hvr as a code owner May 21, 2019 05:22
ntc2 added a commit to ntc2/async that referenced this pull request May 21, 2019
By implementing it using `showsPrec` instead of `show`, so that it
will optionally insert parentheses. Here's an example

    import Control.Concurrent.Async
    import Control.Concurrent
    import Control.Exception

    main :: IO ()
    main = do
      let oneSecond = 1000000
      a <- async $ do
        a <- async $ do
          evaluate $ 1 `div` 0
          return ()
        link a
        threadDelay oneSecond
        wait a
      link a
      threadDelay oneSecond
      wait a

Running this program produces

    ./Test
    Test: ExceptionInLinkedThread ThreadId 2 ExceptionInLinkedThread ThreadId 4 divide by zero

But with the change in the current commit, and some related GHC
PRs (ghc/ghc#254,
ghc/ghc#253), it should produce

    ./Test
    Test: ExceptionInLinkedThread (ThreadId 2) (ExceptionInLinkedThread (ThreadId 4) divide by zero)

instead.
@mpickering
Copy link
Contributor

Please can you open this MR on gitlab?

@ntc2
Copy link
Contributor Author

ntc2 commented May 21, 2019

@mpickering done: https://gitlab.haskell.org/ghc/ghc/merge_requests/1001. Sorry, I hadn't realized that trivial PRs were no longer accepted on GitHub.

@ntc2 ntc2 closed this May 21, 2019
kcsongor pushed a commit to kcsongor/ghc that referenced this pull request Jan 7, 2021
tidyType: also tidy multiplicities
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants