Perspectives on learning and using Haskell

Graham Klyne gk at ninebynine.org
Wed Dec 24 10:39:33 EST 2003


[switching to Haskell-cafe]

At 19:37 23/12/03 +0100, Tomasz Zielonka wrote:
>On Tue, Dec 23, 2003 at 05:26:20PM +0000, Graham Klyne wrote:
>
> > [1] http://www.ninebynine.org/Software/Learning-Haskell-Notes.html
>
>Thanks, that was a nice reading :)

Thanks!

(If by any chance there's anything here that might be useful for the Wiki, 
anyone may feel free to plunder it.)

>I have some comments:
>
>8. Your explanation of Functor excludes many useful Functors which are
>    rather not collections. For example, every monad (like IO) can
>    be a Functor if you take fmap = Monad.liftM.
>
>    For [] and Maybe this would give the same operation as in their
>    normal instances.

That's an interesting perspective that I wasn't aware of... I need to think 
about that.  Meanwhile, I've added your observation to my notes.

[later]

It now seems to me that (some?) Monads are kinds of Functors, generalized 
to handle the "no value" case, and also composition.

This also had me thinking about sequence:  is there a generalization to 
arbitrary monads that rearranges the monadic structure?

>11 and 18.
>    If you define an instance of Monad for ((->) e) then
>
>       return (putStrLn "Hello!") 'x'
>
>    is a proper IO () value. Probably still not sensible ;)

Ah, I think I see your point.  It would apply where monads are "nested", right?

>    Special treatment of 'return' could be helpful, but I am afraid that
>    it could also make it look special, like a return keyword in C.

I certainly wouldn't argue for special treatment _in the language_, but 
OTOH, I think it might be helpful if compiler diagnostics hinted at the 
possibility when a type error is detected in a form like return x y.

#g


------------
Graham Klyne
For email:
http://www.ninebynine.org/#Contact



More information about the Haskell-Cafe mailing list