Hi everyone,<br><br>I'm working on a computational algebra program and I've run into a problem. In my program, I have types for instances of algebraic objects, e.g. ZModN for modular integers, and types for the objects themselves, e.g. ZModNTy for the ring of modular integers.<br>
<br>Now, I want to subclass ZModNTy from something like<br><br>class RingTy a b where<br> order :: a -> Integer<br> units :: a -> [b]<br><br>where `a' represents algebraic object, and `b' the type of instances of that object. I want an instance<br>
<br>instance RingTy ZModNTy ZModN where ...<br><br>but then code that only uses order fails with errors like<br><br> No instance for (RingTy ZModNTy b)<br> arising from a use of `order' at Test2.hs:16:8-15<br>
<br>since there is no constraint on the second type variable.<br><br>I think what I really want is<br><br>class RingTy a where<br> order :: a b -> Integer<br> units :: a b -> [b]<br><br>but this doesn't work either since ZModNTy is not parametric in its type like, say, `Polynomial a' is.<br>
<br>Is this a common problem? Is there a standard way to handle it?<br><br>Thank you for your attention,<br><br>Cotton<br><br>