On 14/04/11 13:00, Chris Dew wrote:
class Stream a b c d where
     (->>) :: a ->  (b ->  c) ->  d

instance Stream (IO d) d (IO c) (IO c) where
     f ->>  g = f>>= g

instance Stream d d (IO c) (IO c) where
     f ->>  g = g f

instance Stream d d c c where
     x ->>  y = y $ x


I notice that in all your instances, the last two types are the same. So do you need the final type parameter? Could you not make it:

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

I quickly tried this, and it fixes the errors you were getting. If that doesn't hold for all instances you have in mind, then you may want to use functional dependencies or type families to specify a relationship between the types.

Thanks,

Neil.


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to