Cetin Sert wrote:
class Streamable a where
  to :: a -> Stream a

The type of to looks wrong for me. a -> Stream a means to takes a single element into a stream of such elements, but you probably want to convert between different representations of streams of elements.

toStream :: [a] -> Stream a

instance Streamable [a] where
  to = toStream                       -- ERROR: see below

Here to :: [a] -> Stream [a] and toStream :: [a] -> Stream a. These types are different, as ghc complained.

Possible solutions include multi parameter type classes

  class Streamable s a where
    to :: s -> Stream a

  instance Streamable [a] a where
    to = toStream

and constructor classes

  class Streamable s where
    to :: s a -> Stream a

  instance Streamable [] where
    to = toStream

Tillmann
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to