Hi Henning, The numeric prelude was inspiration for a lot of my design. Part of the reason I didn't use it was because one of my goals is to learn Haskell better, and I wanted to grapple with these design decisions myself. I decided, like IsZeroTestable in the numeric prelude, to make zero/one separate type classes. Thus, I have class AbelianGroup a where (+) :: a -> a -> a negate :: a -> a class HasZero a where zero :: a so ZModN is an instance of AbelianGroup but not HasZero. Most functions that "want" a zero have two forms, for example, sum :: (HasZero a, AbelianGroup a) => [a] -> a sumWithZero :: (AbelianGroup a) => a -> [a] -> a although I may eventually require all types to have a corresponding Ty class and change this to sumWithTy :: (AbelianGroup a) => AblieanGroupTy a -> [a] -> a Matrices are another example that fits this model. Numeric prelude defines zero/one to be 1x1 matrices, but asserts dimensions match in various operations, so they don't actually seem usable. Cotton On Thu, Jul 3, 2008 at 1:22 AM, Henning Thielemann <lemming@henning-thielemann.de> wrote:
On Wed, 2 Jul 2008, Cotton Seed wrote:
Hi everyone,
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.
Maybe you are also interested in: http://darcs.haskell.org/numericprelude/src/Number/ResidueClass.hs http://darcs.haskell.org/numericprelude/src/Number/ResidueClass/