[Haskell-cafe] Type Classes in Haskell - how can I make GHC make a choice of types, when the type chosen doesn't matter?

Stephen Tetley stephen.tetley at gmail.com
Thu Apr 14 15:28:16 CEST 2011


Hi Chris

What does the Stream class *do* though?

class Stream a b c d where
    (->>) :: a ->  (b ->  c) ->  d

Even with Neil's change its still quite unusual:

class Stream a b c where
 (->>) :: a -> (b -> c) -> c

In the first formulation there is an input of type a, a function (b ->
c) and a result of a completely different type d.

In Neil's class the function relates to the type of the answer but not
to the input.

The "difficult" type classes in Haskell - Applicative, Monad, and
Arrows / Category - are related to some degree to fairly standard
combinators on functions. But they generalize the combinators to
operate on other types than the function type (->). As there isn't a
relation between input and output, I don't quite see how the Stream
type could start as a combinator.

Best wishes

Stephen



More information about the Haskell-Cafe mailing list