[Haskell-cafe] Type classes

Max Vasin max-appolo at mail.ru
Mon Mar 20 09:46:43 EST 2006


Hi!

I'm currently experimenting with a bibliography generation tool for
LaTeX. It will (if it will be finished) use BibTeX databases but
bibliography styles will be written in Haskell. I want styles to be
able to transform database entries into some style specific data type,
so I define 

> class DatabaseEntry e where
>       entryLabel     :: e -> String
>       formatEntry    :: e -> String
>       compareEntries :: e -> e -> Ordering

Then I define

> data Entry = forall a. (DatabaseEntry a) => Entry a

> instance DatabaseEntry Entry where
>     entryLabel (Entry e) = entryLabel e
>     formatEntry (Entry e) = formatEntry e

How can I define compareEntries for this instance?

-- 
WBR,
Max Vasin.



More information about the Haskell-Cafe mailing list