Functor => Applicative => Monad
Maciej Piechotka
uzytkownik2 at gmail.com
Mon Dec 6 18:26:17 CET 2010
On Mon, 2010-12-06 at 15:47 +0000, Stephen Tetley wrote:
> Me thinks there's more value that "the next language after Haskell"
> might have such a hierarchy than Haskell itself.
>
> At Haskell 1.3 I think there was one text book (Davie), possibly none
> at Haskell 1.4 and many at Haskell 98. The value of invalidating 12 or
> so years of documentation for "logic" seems somewhat questionable from
> my perspective. If either proposal were limited to just adding class
> constraints to get the desired hierarchy rather than eliminating
> methods, they might have more legs...
As far as I understend you, you would prefer:
class Functor f where
fmap :: (a -> b) -> f a -> f b
class Functor f => Applicative f where
pure :: a -> f a
(<*>) :: f (a -> b) -> f a -> f b
(*>) :: f a -> f b -> f b
(<*) :: f a -> f b -> f a
class Applicative m => Monad m where
(>>) :: m a -> m b -> m b
(>>) = (*>)
(>>=) :: m a -> (a -> m b) -> m b
f >>= x = join $ map f x
return :: a -> m a
return = pure
join :: m (m a) -> m a
join x = x >>= id
or.
class Functor f where
fmap :: (a -> b) -> f a -> f b
class Functor f => Pointed f where
point :: a -> f a
class Pointed f => Applicative f where
pure :: a -> f a
pure = point
(<*>) :: f (a -> b) -> f a -> f b
(*>) :: f a -> f b -> f b
(<*) :: f a -> f b -> f a
class Applicative m => Monad m where
(>>) :: m a -> m b -> m b
(>>) = (*>)
(>>=) :: m a -> (a -> m b) -> m b
f >>= x = join $ map f x
return :: a -> m a
return = pure
join :: m (m a) -> m a
join x = x >>= id
Regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://www.haskell.org/pipermail/libraries/attachments/20101206/79930e31/attachment.pgp>
More information about the Libraries
mailing list