Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,260
    • Issues 4,260
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 402
    • Merge Requests 402
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #8470

Closed
Open
Opened Oct 22, 2013 by 2piix@trac-2piix

"Fix" spurious Unused do-bind warnings

I've been writing a lot of monadic code with side effects, and I'm getting a lot of unused do-bind warnings.

In particular, consider the contrived example:

performSideEffect :: IO ()
preformSideEffect = return ()

someComplicatedIOAction :: a -> IO ()
someComplicatedIOAction a = do
   a <- getA
   performSideEffect
   putStrLn . show $ a

The call to performSideEffect triggers the unused do-bind warning.

I can appreciate that we're not binding result of performSideEffect, but we know, by virtue of the type () being a singleton, that there is nothing we can do with the the result. So it "really" doesn't make sense to pull anything out of the action. Fixing the warning with _ <- performSideEffect just adds noise.

Would it be possible to turn off the warning in the case that the monad action returns (), or maybe even other singleton types? I'm guessing the latter is harder, and I'd be happy to settle for just (). I don't know enough about GHC's internals to evaluate how hard either would be, though.

I know about -fno-warn-unused-do-bind, but it is inconvenient to use in a project that uses -Wall in the Cabal file, which a fairly popular web application framework uses. Even still, catching the legitimate unused do-binds while eliminating these spurious ones would be a nice, noise-lowering addition.

Trac metadata
Trac field Value
Version 7.6.3
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#8470