@Neil Brown - That did it. It's not the ideal solution, as all ->> are 'coerced' into being 'IO x' (if the rightmost term is an 'IO x'. But it'll do for the time being.
Many thanks, Chris. On 14 April 2011 13:50, Neil Brown <[email protected]> wrote: > 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 [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
