GHC: Ticket #3292: Add an 'ignore' function to Control.Monad
http://ghc.haskell.org/trac/ghc/ticket/3292
<p>
See <a class="ext-link" href="http://www.haskell.org/pipermail/libraries/2009-June/thread.html#11880"><span class="icon"></span>http://www.haskell.org/pipermail/libraries/2009-June/thread.html#11880</a>
</p>
<p>
In short, add a 'ignore :: m a -> m ()' function to Control.Monad. This lets us do things like 'forkIO $ ignore stuff', as opposed to throwing around all sorts of '>> return ()'.
</p>
<p>
This function could be widely used by many libraries & apps, and has been repeatedly invented and suggested (see the thread). So far no one has said a word against it.
</p>
<pre class="wiki">- -- | Convenience function. This is particularly good for 'forkIO' and 'forM_',
-- as they demand return types of 'IO ()', but most interesting IO functions
-- don't return void. So one can wrap them with 'ignore' (essentially a call to 'unit').
ignore :: Functor f => f a -> f ()
ignore = fmap (const ())
</pre>en-usGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.png
http://ghc.haskell.org/trac/ghc/ticket/3292
Trac 1.2.2.dev0guestThu, 11 Jun 2009 10:53:36 GMT
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:1
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:1
<p>
<a class="ext-link" href="http://www.nabble.com/Adding-an-ignore-function-to-Control.Monad-td23966574.html"><span class="icon"></span>Nabble link for those who use it</a>
</p>
TicketguestFri, 12 Jun 2009 01:30:47 GMTattachment set
http://ghc.haskell.org/trac/ghc/ticket/3292
http://ghc.haskell.org/trac/ghc/ticket/3292
<ul>
<li><strong>attachment</strong>
set to <em>ignore.dpatch</em>
</li>
</ul>
<p>
Patch adding ignore to base
</p>
TicketdonsWed, 01 Jul 2009 20:14:00 GMT
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:2
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:2
<p>
This is a generalization of the well-known FFI 'void' function:
</p>
<pre class="wiki">module Foreign.Marshal.Error
-- |Discard the return value of an 'IO' action
--
void :: IO a -> IO ()
void act = act >> return ()
</pre><p>
in base for the last decade. Generalising 'void' (with that name), seems more intuitive to me.
</p>
TicketiglooSun, 12 Jul 2009 18:26:43 GMTdifficulty, milestone set
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:3
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:3
<ul>
<li><strong>difficulty</strong>
set to <em>Unknown</em>
</li>
<li><strong>milestone</strong>
set to <em>Not GHC</em>
</li>
</ul>
TicketguestFri, 08 Jan 2010 21:53:57 GMTattachment set
http://ghc.haskell.org/trac/ghc/ticket/3292
http://ghc.haskell.org/trac/ghc/ticket/3292
<ul>
<li><strong>attachment</strong>
set to <em>void.dpatch</em>
</li>
</ul>
<p>
amended version; functor, name change, and more laconic documentation
</p>
TicketguestFri, 08 Jan 2010 21:55:22 GMTfailure set
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:4
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:4
<ul>
<li><strong>failure</strong>
set to <em>None/Unknown</em>
</li>
</ul>
<p>
I've attached a new patch, one using the 'void' name and Functor type signature.
</p>
<p>
(I wondered about the section to put it in, but then I realized 'forever' wasn't in the Prelude either, so 'void' would be as happy there.)
</p>
TicketguestFri, 08 Jan 2010 21:59:37 GMT
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:5
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:5
<p>
My final headcount of the very long discussion is here: <a class="ext-link" href="http://www.haskell.org/pipermail/libraries/2010-January/012972.html"><span class="icon"></span>http://www.haskell.org/pipermail/libraries/2010-January/012972.html</a>
</p>
<p>
I think it's clear that there's overwhelming support for adding void/ignore, with minor quibbling over the exact name & type signature. void :: f a -> f () is the best compromise, I think, and I hope now that Don's point about 'void' has been addressed, igloo or someone could add it to base.
</p>
TicketguestTue, 12 Jan 2010 21:56:12 GMT
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:6
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:6
<p>
What needs to be done to get this applied? Since the patch/email/ticket flurry 4 days, there haven't even been any objections. Is there someone I need to specifically email or chat with in #haskell?
</p>
<p>
--gwern
</p>
Ticketmalcolm.wallace@…Tue, 12 Jan 2010 22:22:34 GMTversion, type changed
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:7
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:7
<ul>
<li><strong>version</strong>
changed from <em>6.10.2</em> to <em>6.12.1</em>
</li>
<li><strong>type</strong>
changed from <em>proposal</em> to <em>merge</em>
</li>
</ul>
<p>
Patch applied. Should it be merged to the ghc-6.12.x branch?
</p>
TicketguestTue, 12 Jan 2010 23:16:21 GMT
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:8
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:8
<p>
Malcolm: I don't see any reason why it shouldn't be, do you?
</p>
<p>
(I suppose this would involve issues of base's version-number, but I don't know anything about that.)
</p>
TicketrossTue, 12 Jan 2010 23:31:51 GMTstatus, type, version changed; resolution set
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:9
http://ghc.haskell.org/trac/ghc/ticket/3292#comment:9
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>type</strong>
changed from <em>merge</em> to <em>proposal</em>
</li>
<li><strong>version</strong>
changed from <em>6.12.1</em> to <em>6.13</em>
</li>
<li><strong>resolution</strong>
set to <em>fixed</em>
</li>
</ul>
<p>
We don't change the API of core packages during the cycle.
</p>
Ticket