[Haskell-cafe] Re: How to "Show" an Operation?
lrpalmer at gmail.com
Fri Jun 11 01:39:22 EDT 2010
On Thu, Jun 10, 2010 at 10:43 PM, Brandon S. Allbery KF8NH
<allbery at ece.cmu.edu> wrote:
> On Jun 10, 2010, at 17:38 , Martin Drautzburg wrote:
>>> instance Applicative Named where
>>> pure x = Named "" x
>>> (Named s f) <*> (Named t v) = Named (s ++ "(" ++ t ++ ")") (f v)
>> Applicative. Need to study that
> The above is just the Functor, rephrased in Applicative style. <*> is
> exactly fmap. Likewise, Monad has a function "liftM" which is exactly fmap.
> (For historical reasons, these are not related the way they should be: all
> Monads should be Applicatives, all Applicatives should be Functors, and all
> Functors should be instances of an even more primitive class Pointed.)
(<*>) :: Applicative f => f (a -> b) -> f a -> f b
(<$>) :: Functor f => (a -> b) -> f a -> f b
(<$>) is fmap, not (<*>). (<*>) is available for monads as Control.Monad.ap.
More information about the Haskell-Cafe