[Haskell-beginners] in which monad am I?

Francesco Guerrieri f.guerrieri at gmail.com
Sun Jan 3 18:02:41 EST 2010


On Sun, Jan 3, 2010 at 11:30 PM, Felipe Lessa <felipe.lessa at gmail.com> wrote:
> On Sun, Jan 03, 2010 at 10:38:28PM +0100, Francesco Guerrieri wrote:
>> But doesn't ever happen that poor liftM be confused? and do poor
>> haskell programmers never feel the need to explicitly state to which
>> monad they "wish to lift" ?
>
> If by "explicitly state to which monad" you mean specializing
> liftM or fmap, then the answer is no.  It is not uncommon to see
>
>  fmap (fmap function)
>
> being used to map two layers of structures.  If by stating you
> mean giving a type signature, then yes, it is a good practice to
> give type signatures to all top-level definitions.

I was thinking to type signatures :-)
By the way, you all refer to top-level definition. But in the map show
. map read example, what I see at the top-level is
[String] -> [String]. This probably means that my understanding of
what is a top-level definition is faulty...

> The compiler never gets "confused".  The only thing that may
> happen is having more than one possible type that fulfills your
> needs.  The classical example is Num overloading:

This is a very clear example, thanks!

Francesco


More information about the Beginners mailing list