[Haskell-beginners] Relation between monads and computations
sgf.dma at gmail.com
Thu Feb 16 10:39:27 CET 2012
> > > > Now, using fucntions unitM and bindM there is possibly to convert arbitrary
> > > > function (k :: a -> b), which makes from initial value of type a value of type
> > > > b, into terms of general computation (represented by type M).
> > >
> > > Yes, (k :: a -> b) can be converted into a function of type (a -> M
> > > b), but I think you have made it more complicated than necessary. All
> > > you need to do is (unitM . k).
> > Hmm, so i was wrong here. Initially, i suppose, that the purpose of bindM is
> > to convert function of type (a -> b) into function of type (a -> M b), but now
> > i see it is wrong. Mentioned above quote from  says, that "the purpose of
> > bindM is to evaluate a computation, yielding a value.", which sounds a little
> > unfinished to me. Then may be: the purpose of bindM is to make composition
> > of functions of type (a -> M b) and (b -> M c) possible. Is this
> > right?
> Yes! In fact, there is a standard operator
> (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> (a -> m c)
> which is defined in terms of bind. Implementing it is a good
> By the way, you may be interested in reading the Typeclassopedia:
Thank you very much, Brent! I'll try what you advise and read this link. And
then may be ask again.. :)
More information about the Beginners