
7 Aug
2007
7 Aug
'07
9:46 a.m.
DavidA wrote:
newtype Lex = Lex Monomial deriving (Eq) newtype Glex = Glex Monomial deriving (Eq)
Now, what I'd like to do is have Lex and Glex, and any further monomial orderings I define later, automatically derive Show and Num instances from Monomial (because it seems like boilerplate to have to define Show and Num instances by hand).
Good news: it's already implemented and called newtype deriving :) http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html... In short, you just write newtype Lex = Lex Monomial deriving (Eq, Show, Num) I guess that the Show instance will add the constructor Lex , though. Regards, apfelmus