[Haskell] Re: Mixing monadic and non-monadic functions

Tomasz Zielonka tomasz.zielonka at gmail.com
Fri Sep 16 06:19:28 EDT 2005


On Sun, Sep 11, 2005 at 01:48:16AM -0400, Cale Gibbard wrote:
> On 10/09/05, Frederik Eaton <frederik at a5.repetae.net> wrote:
> > These are good arguments, and I think this is a good direction for the
> > discussion, should it continue.
> > 
> > > Despite having a fairly mathematical background, I don't really care
> > > for the proposed syntax.
> > >
> > > myList :: [[Integer]]
> > > myList = return [1,2,3,4]
> > 
> > I'm assuming you mean
> > 
> > myList :: [[Integer]]
> > myList = [1,2,3,4]
> 
> No, the confusion is over whether to lift the return, because the
> inner and outer monads are the same. It's either return [1,2,3,4] ==
> [[1,2,3,4]], or it's liftM return [1,2,3,4] == [[1],[2],[3],[4]]

I think that Frederik's example is even better. Here you either lift the
entire list or each individual number:

    return [1,2,3,4]

or

    [return 1,return 2,return 3,return 4]

After all, return is only a fancy name for liftM0 ;-)

Best regards
Tomasz


More information about the Haskell mailing list