[Haskell-cafe] Trapped by the Monads

Greg Buchholz haskell at sleepingsquirrel.org
Tue Sep 20 17:05:29 EDT 2005

Mark Carter wrote:
> What struck me was this bit of code:
> assemblyLine w = (return w) >>= makeChopsticks >>= polishChopsticks >>= 
> wrapChopsticks
> Interestingly, this looks like Forth (!), where you put a value on the 
> stack, and successive operations fiddle with the stack as a series of 
> transformations. Not that I know Forth, you understand. Hmm, so Haskell 
> can be a concatenative language if you want it to be.

  You might also like take a look the Joy language...


...sort of a functional, higher level cousin of Forth.  In Joy, you
create programs by composing functions with other functions.  This is in
contrast to other languages where functions are mainly applied to other
functions (and data).  The composition operator Joy is denoted by white
space.  This is similar to the way juxtaposition is used to denote
function application in more conventional languages.  (i.e., in Joy "f
g" means "g" composed with "f", while in other languages "f(g)" means
apply function "f" to argument "g").  Now, what if we had a name for
this implicit composition operation?  We could then modify it to do a
whole host of other things with the functions "f" and "g" besides just
the boring old composition (like maybe skipping the execution of "g" if
"f" fails, or allowing backtracking, or something more bizarre and
clever).  And what should we name this new super composition operator?
">>=" maybe?  Ah... 

Greg Buchholz

More information about the Haskell-Cafe mailing list