[Haskell-cafe] Why Kleisli composition is not in the Monad signature?

Ben Franksen ben.franksen at online.de
Fri Nov 30 23:00:02 CET 2012

Gershom Bazerman wrote:
> On 11/30/12 10:44 AM, Dan Doel wrote:
>> Lists! The finite kind.
>> This could mean Seq for instance.
>> On Nov 30, 2012 9:53 AM, "Brent Yorgey" <byorgey at seas.upenn.edu 
>> <mailto:byorgey at seas.upenn.edu>> wrote:
>>     Any data type which admits structures of arbitrary but *only finite*
>>     size has a natural "zippy" Apply instance but no Applicative (since
>>     pure would have to be an infinite structure).  The Map instance I
>>     mentioned above falls in this category.  Though I guess I'm having
>>     trouble coming up with other examples, but I'm sure some exist.  
>>     Edward knows of other examples.
> Another common case would be an embedded DSL representing code in a 
> different language, targeting a different platform (or even an FPGA or 
> the like), etc. You can apply `OtherLang (a -> b)` to an `OtherLang a` 
> and get an `OtherLang b`, but you clearly can't promote (or "lower," I 
> guess) an arbitrary Haskell function into a function in your target 
> language. This is the same reason that GArrows remove the `arr` function 
> (http://www.cs.berkeley.edu/~megacz/garrows/).

A fine example! And I am getting the drift... yes, this could be a useful 

Now, on to Bind: the standard finite structure example for Bind is most 
probably the substitution thingy, i.e. if m :: m a, f :: a -> m b, then m 
>>= f means replace all elements x :: a in m with f x and then flatten the 
result so it's an m b again. Like concatMap for lists, right? So, there is 
no return for that in the Map case for exactly the same reason as with 
Apply: the unit would have have value id for every possible key, so cannot 
be finite.

So what about an example for Bind\\Monad that is not yet another variation 
of the finite structure theme?

Ben Franksen
()  ascii ribbon campaign - against html e-mail 
/\  www.asciiribbon.org   - against proprietary attachments

More information about the Haskell-Cafe mailing list