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

Unsafe operations lead to delayed OS responses (such as stderr content) #22

Open
andreasabel opened this issue Aug 21, 2022 · 0 comments

Comments

@andreasabel
Copy link

andreasabel commented Aug 21, 2022

find lives in IO, but nevertheless uses unsafePerformIO.

import System.IO.Unsafe (unsafeInterleaveIO, unsafePerformIO)

This leads to weird effects.
E.g. I experienced that on Windows some warnings cause by find are printed to stderr only after the results produced by find were inspected. This forced me to wrap find into Control.Exceptions.evaluate to trigger the printing of warnings at the correct moment.
Details are here: https://github.com/andreasabel/cabal-clean/blob/015cf3d6bda2e7b9118f3b19f50e27c70592d75c/src/DiscoverGHCs.hs#L30-L33

  ghcs <- hSilence [stderr] $ do -- Silence warnings about broken symlinks produced by @find@.
    evaluate =<< do              -- Needed under Windows, otherwise warnings are raised too lazily
                                 -- and not caught by @hSilence@.
      concat <$> mapM (find recursionP filterP) path

unsafePerformIO: Your pact with the devil. Experience pleasure now, pay in eternity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant