Monthly Hask Anything (December 2022)

has anyone used the hmatrix library?

I'm trying to do stuff with matrices over the field with two elements, which I'm calling Z2. But to do practically anything with Matrix a requires an instance for CTrans a. The typeclass seems simple; it just tells you how to transpose a matrix with elements in a. The only issue is that the typeclass is internal, and there seems to be no way for me to reference it!

It's especially frustrating since, looking at the source code, the class's only method has a default implementation that's correct for my use case. So if I could only refer the class, I could literally just write "instance CTrans Z2" and everything would work.

Presumably there's some way to make the library work on matrices Matrix a for types other than what the library comes with, but for the life of me I can't figure out how. (And if for some reason it's not possible, does anyone have a recommendation for a reasonably well-featured linear algebra/matrix library, with stuff like reduction to row-echelon form?)

/r/haskell Thread