Haskellians,<br><br>i am delighted to see vigorous exchange that actually resulted in change of positions. i confess i was going to give up, but glad others stepped into the breach. This is yet another indication of what an unusual community this is.
<br><br>Best wishes,<br><br>--greg<br><br>Date: Fri, 3 Aug 2007 13:43:32 +1200<br>From: ok <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:firstname.lastname@example.org">email@example.com</a>><br>Subject: Re: RE [Haskell-cafe] Monad Description For Imperative
<br>To: haskell-cafe Cafe <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:firstname.lastname@example.org">email@example.com</a>><br>Message-ID: <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:8575BD1C-2113-4D48-A3D4-BDFF41238BB9@cs.otago.ac.nz">
8575BD1C-2113-4D48-A3D4-BDFF41238BB9@cs.otago.ac.nz</a>><br>Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed<br><br>I asked "How is IO a functor"?<br><br>On 3 Aug 2007, at 11:50 am, Dan Piponi wrote:
<br>> IO is a fully paid up Monad in the categorical sense. The category is<br>> the category whose objects are types and whose arrows are functions<br>> between those types. IO is a functor. The object a maps to IO a. An
<br>> arrow f::a->b maps to (>>= return . f)::IO a -> IO b and that can be<br>> used to make IO an instance of Functor. The natural transforms eta and<br>> mu are called return and join.<br><br><br>Please go over this again, but slowly this time.
<br>You have convinced me, but I'd like to understand the details a little<br>better.<br><br>I see that any type constructor TC :: * -> * is halfway to being a<br>functor<br>on this category of types. It acts on the objects in the obvious way,
<br>so the next step is to see about the arrows.<br><br> If f :: a -> b then we want TC f :: TC a -> TC b<br><br>such that TC (f . g) = TC f . TC g and TC (id::a->a) = id :: TC a -><br>TC a<br><br>Now this is precisely the Haskell Functor class, so TC is the object
<br>part<br>and fmap is the arrow part. You say that (>>= return . f) can be<br>used to<br>make [a Monad] an instance of Functor. Try it... by golly it's true.<br>I see: fmap f = (>>= return . f).<br><br>
So why *aren't* Monads already set up using the type class machinery<br>to always *be* Functors in Haskell? Isn't it bound to confuse people<br>if monads are functors but Monads are not Functors?<br><br>This is especially puzzling because Maybe, , and IO already *are*
<br>Functors, but the way this is done makes it look accidental, not like<br>the fundamental property of Monads it apparently is.<br><br>(By the way, I note that the on-line documentation for Control.Monad<br>glosses<br> >>= as "Sequentially composes two actions...".)
<br><br clear="all"><br>-- <br>L.G. Meredith<br>Managing Partner<br>Biosimilarity LLC<br>505 N 72nd St<br>Seattle, WA 98103<br><br>+1 206.650.3740<br><br><a href="http://biosimilarity.blogspot.com">http://biosimilarity.blogspot.com