Add Applicative instance for STM
Ross Paterson
ross at soi.city.ac.uk
Sun May 16 10:19:46 EDT 2010
On Sun, May 16, 2010 at 01:54:28PM +0200, Bas van Dijk wrote:
> I was rewriting my threads package to use TVars instead of MVars when
> I noticed that the following gave a type error:
> new ∷ IO ThreadGroup
> new = atomically $ ThreadGroup <$> newTVar 0 <*> newTMVar ()
> because of a missing Applicative instance for STM.
>
> So I propose adding one:
>
> http://hackage.haskell.org/trac/ghc/ticket/4076
>
> Note I had to create a base/Control/Applicative.hs-boot file and import
> Applicative using {-# SOURCE #-} because I got a "Module imports form
> a cycle for modules" error.
It might be simpler to have Control/Applicative.hs import GHC.Conc and
define the instance.
Might as well define an Alternative instance too.
It would also make sense to move the MonadPlus instance from Control.Monad.STM
(where it is an orphan) to GHC.Conc.
> Discussion period: a few days, since I think this is hardly controversial.
I think proposals should get at least a couple of weeks, even if they're
straightforward.
More information about the Libraries
mailing list