Twan van Laarhoven wrote:
I some cases Applicative is a huge win. Simon's argument is that it is not
possible to use consistently everywhere. I agree that we should strive to have a single style for different cases in a single function. However, there are a lot of functions that become significantly simpler with Applicative. Random example:

    dsLookupGlobalId :: Name -> DsM Id
    dsLookupGlobalId name
      = tyThingId <$> dsLookupGlobal name

Not only is it shorter than the corresponding monadic code, it is also
conceptually simpler.

and it also has nothing to do with Applicative, only Functor; it could be fmap

     dsLookupGlobalId :: Name -> DsM Id
     dsLookupGlobalId name
       = tyThingId `fmap` dsLookupGlobal name
or
       = fmap tyThingId (dsLookupGlobal name)

I suppose some of your examples are more difficult than this one, though. Please don't forget Control.Monad.liftM# and Control.Monad.ap (though it's debatable if it's preferable to use those than the Applicative names liftA# and especially <*>, or if even the monad-versions make the code too confusing)

~Isaac

_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to