[Haskell-cafe] Modulo-foo equivalence classes in Haskell?
dnavarro at gmail.com
Thu Feb 1 07:19:06 EST 2007
Watching the questions go by in #haskell, a still fuzzy but possibly
pregnant idea popped up in my mind. Someone needed a nubBy function
that returned an unique list modulo an arbitrary function foo. Well,
in this case it wasn't arbitrary; he had a list of transposable
matrices and wanted an unique list of matrices that couldn't be
transposed into each other.
I'm thinking there are many cases of fooBy functions that have to be
constantly rewritten, and also a lot of ugly code by having to
constantly add the modulo clauses (like in modular arithmetic).
I'm inexperienced with type classes -- I've only done the simplest
types and /some/ fundeps -- so I'm wondering what would be the
clearest, most general way of having a Modulo-foo Eq class that could
be parameterized with a function. The "transposable matrix" example
shows how this could be useful for (some limited form) of data
compression, but it could make some other forms of "algebraically
modular" (this is not a proper term, it's me trying to get thoughts
across) business rules, of which modular arithmetic is a special case.
Uh, I've probably not expressed myself well enough; I hope I have a
shot at trying to explain myself better if questions come up.
-- Diego Navarro
More information about the Haskell-Cafe