[Haskell-beginners] Haskell wants the type, but I only know the class.

Antoine Latter aslatter at gmail.com
Thu Nov 3 18:48:55 CET 2011


On Thu, Nov 3, 2011 at 11:55 AM, Amy de Buitléir <amy at nualeargais.ie> wrote:
> I'm trying to read something from a file, do something with it, and then write
> it out again. I don't know, or care about, the type of the object I'm reading,
> but I do know its class. Here's my code:
>
> ----------
> import Data.Binary ( Binary, encode, decode )
> import Data.ByteString.Lazy as B ( readFile, writeFile )
> import Codec.Compression.GZip ( compress, decompress )
>
> class ( Binary a, Show a, Eq a ) => Thing a where
>  doSomething :: a -> IO a
>



More information about the Beginners mailing list