[Haskell-beginners] Monadic composition without throwing genericity under the bus?

Dave Bayer bayer at cpw.math.columbia.edu
Wed Feb 3 23:45:14 EST 2010


Let me be as concise as I can, for a second try.

One can't make a function-valued monad into an instance of Category, because a Category takes two type arguments, while a Monad takes one?

I'm having serious cognitive dissonance here. The "back 40 acres" of the GHC manual is filled with brilliant work-arounds and references to research papers for far more arcane type dilemmas than this. My local hardware store is filled with pieces of copper that fit 1/2" pipe to 3/4" pipe, and they don't check for Ph.Ds at the door. But there's no provision in the language to fit a type class taking two arguments to a type class taking one argument?

I simply can't believe that I'm the first person to stumble over this. Either this is a famous rough edge, and others can list off a dozen similar circumstances where one gets stuck, or there's an easy work-around I'm just not seeing.

Can anyone confirm that it's simply not possible to plumb type classes the way I want to plumb them? If so, should I be proposing a language extension on a different mailing list?

On Feb 2, 2010, at 11:08 AM, Daniel Fischer wrote:

> You can help it somewhat by adding more FunDeps to Composable,
> 
> class Composable a b c | a b → c, a c→ b, b c→ a where
>    compose ∷ a → b → c

That's nice, I didn't think of that, but as you say it doesn't fix the problem.



More information about the Beginners mailing list