[Haskell] A collection of related proposals regarding monads
Cale Gibbard
cgibbard at gmail.com
Thu Jan 5 14:54:17 EST 2006
On 05/01/06, Taral <taralx at gmail.com> wrote:
> On 1/5/06, Cale Gibbard <cgibbard at gmail.com> wrote:
> > class Applicative m => Monad m where
> > m >>= f = join (map f m)
> >
> > instance PointedFunctor m where
> > require return
> > map f x = x >>= (return . f)
>
> Um, it looks like map and (>>=) are recursive...
>
The intent is that this is similar to other default method
declarations which aren't really recursive, though they may look like
it.
>From the Ord class in the Prelude, we have:
compare x y
| x == y = EQ
| x <= y = LT
| otherwise = GT
x <= y = compare x y /= GT
....
Which looks recursive, but it's not, because the user is required to
provide one of the two.
- Cale
More information about the Haskell
mailing list