-
Notifications
You must be signed in to change notification settings - Fork 701
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
WIP: Adapt to simplifed subsumption proposal #6545
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are few issues I can spot, but in general this is something for @ezyang to review.
@@ -126,7 +131,9 @@ defaultMainHelper args = | |||
,unregisterCommand `commandAddAction` unregisterAction | |||
] | |||
|
|||
configureAction :: ConfigFlags -> [String] -> IO () | |||
type Action flags = flags -> [String] -> Prelude.IO () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes (WithCallStack)IO
to Prelude.IO
, and I guess this is the place where we'd like the CallStack
s to propagate.
@@ -146,6 +146,7 @@ import Distribution.Compat.Environment ( lookupEnv ) | |||
import Distribution.Compat.Exception ( catchExit, catchIO ) | |||
|
|||
import qualified Data.Set as Set | |||
import qualified Prelude (IO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have
type NoCallStackIO a = OrigPrelude.IO a
defined in Distribution.Compat.Prelude
, please don't import Prelude (IO)
.
Link to proposal in description doesn't work/show. |
Yes, my apologies, this is still a WIP. |
(FYI, GitHub has draft pull requests, yet the feature is a bit hidden) |
@ezyang, frankly, given the amount of churn this has caused I do wonder whether these |
Well, the original introduction of CallStack was always predicated on the idea that it was actually really easy to add them, without having to modify any code at all. So if simplified subsumption means a lot of these patterns stop working, it might mean that the cost-benefit analysis has swung the other way. That being said, in the past, I have greatly appreciated having call stacks available default from IO code; it makes it a lot easier to understand what was going on when an error occurred. |
So, to put it more explicitly, I'd accept the version of this patch that just removes the type synonym entirely. It's cool, but it seems like more trouble than it's worth, based on this patch. |
I removed the alias in #6552 |
Thanks for being resonsive to this.
I agree with this, and for the most part it remains the case. But for the use that Cabal makes of it you are really piggy-backing on GHC's implicit eta-expansion, with all the implications that has for work duplication. Often it doesn't matter, but sometimes it'll bite you. Perhaps the ice was thinner than we realised! Anyway, all good now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that as I removed the IO
alias in #6552, this PR is better redone from scratch.
There are few non-IO related needed eta-expansions. For example
-fieldDescrParse (F m) fn = pParse <$> Map.lookup fn m
+fieldDescrParse (F m) fn = (\f -> pParse f) <$> Map.lookup fn m
but I'm not sure if there are more.
Here is the patch that I ended up with after building diff --git a/Cabal/Distribution/FieldGrammar/FieldDescrs.hs b/Cabal/Distribution/FieldGrammar/FieldDescrs.hs
index 803ce603c..f58a918af 100644
--- a/Cabal/Distribution/FieldGrammar/FieldDescrs.hs
+++ b/Cabal/Distribution/FieldGrammar/FieldDescrs.hs
@@ -45,7 +45,7 @@ fieldDescrPretty (F m) fn = pPretty <$> Map.lookup fn m
-- | Lookup a field value parser.
fieldDescrParse :: P.CabalParsing m => FieldDescrs s a -> P.FieldName -> Maybe (s -> m s)
-fieldDescrParse (F m) fn = pParse <$> Map.lookup fn m
+fieldDescrParse (F m) fn = (\f -> pParse f) <$> Map.lookup fn m
fieldDescrsToList
:: P.CabalParsing m
diff --git a/Cabal/Distribution/Simple/Utils.hs b/Cabal/Distribution/Simple/Utils.hs
index d6e8384f1..deeaef243 100644
--- a/Cabal/Distribution/Simple/Utils.hs
+++ b/Cabal/Distribution/Simple/Utils.hs
@@ -1341,7 +1341,7 @@ withTempFileEx opts tmpDir template action =
(\(name, handle) -> do hClose handle
unless (optKeepTempFiles opts) $
handleDoesNotExist () . removeFile $ name)
- (withLexicalCallStack (uncurry action))
+ (withLexicalCallStack (\x -> uncurry action x))
-- | Create and use a temporary directory.
--
@@ -1356,7 +1356,7 @@ withTempFileEx opts tmpDir template action =
withTempDirectory :: Verbosity -> FilePath -> String -> (FilePath -> IO a) -> IO a
withTempDirectory verbosity targetDir template f = withFrozenCallStack $
withTempDirectoryEx verbosity defaultTempFileOptions targetDir template
- (withLexicalCallStack f)
+ (withLexicalCallStack (\x -> f x))
-- | A version of 'withTempDirectory' that additionally takes a
-- 'TempFileOptions' argument.
@@ -1367,7 +1367,7 @@ withTempDirectoryEx _verbosity opts targetDir template f = withFrozenCallStack $
(createTempDirectory targetDir template)
(unless (optKeepTempFiles opts)
. handleDoesNotExist () . removeDirectoryRecursive)
- (withLexicalCallStack f)
+ (withLexicalCallStack (\x -> f x))
-----------------------------------
-- Safely reading and writing files I don't have the power to push this to the branch in this PR, so I leave this to you @bgamari. |
Originally written by Ryan Scott in haskell#6545 (comment)
It looks like the changes in #6545 (comment) have been packaged into a separate PR at #6563, making that PR supersede this one. I'll close this PR in favor of #6563 accordingly. |
Originally written by Ryan Scott in haskell#6545 (comment)
Cabal's
IO a = HasCallStack => IO a
type synonym causes quite sometrouble under the simplified subsumption proposal. Fix these cases
by eta-expanding or adding type signatures where necessary.
Please include the following checklist in your PR:
[ci skip]
is used to avoid triggering the build bots.Please also shortly describe how you tested your change. Bonus points for added tests!