Skip to content

Avoid using Alternative unnecessarily#1304

Open
tomjaguarpaw wants to merge 3 commits intohaskell:masterfrom
tomjaguarpaw:less-alternative
Open

Avoid using Alternative unnecessarily#1304
tomjaguarpaw wants to merge 3 commits intohaskell:masterfrom
tomjaguarpaw:less-alternative

Conversation

@tomjaguarpaw
Copy link
Copy Markdown
Member

Some were completely redundant, some were just unnecessary with a bit of restructuring. This is also a step towards the TODO in getLinuxDistro: "don't do alternative on IO, because it hides bugs".

It just wasn't used. Maybe left over from an older version when it was
used.
Instead of doing Alternative in m, do it in IO and then liftIO into m
Comment thread lib/GHCup/Platform.hs
-- TODO: don't do alternative on IO, because it hides bugs
(name, mid, ver) <- handleIO (\_ -> throwE DistroNotFound) $ lift $ asum
[ liftIO try_os_release
(name, mid, ver) <- join $ liftIO $ handleIO (\_ -> pure (throwE DistroNotFound)) $ fmap pure $ asum
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well yeah... the interesting part is getting rid of asum.

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

Successfully merging this pull request may close these issues.

2 participants