@ApothecaLabs has graciously allowed me to revive this thread because I’ve reached a point in the development of a library with a similar goal, flex, that I feel comfortable sharing my progress. I’ve hinted at this library in another thread, and I’ve included a slightly modified version of the vector math mentioned there in flex as well.
This library initially had the lofty goal of “improving the Num hierarchy”, and I claim that it has achieved it. It includes the theories of additive and multiplicative groups, rings, modules, algebras, and inner product spaces. The instances are tested with the use of Lawvere theories defined similarly to the above reply by @olf:
class Variety (var :: k -> Constraint) where
type Requirements var :: k -> Constraint
data Signature var :: k -> Type
data Operations var :: k -> Type
-- ^ usually a newtype wrapper for `x`
-- c.f. instance Variety Semigroup, instance Variety Module
operations :: (var x) => Signature var x -> Operations var x
data Laws var :: k -> Type
lawful :: (var x, Requirements var x) => Laws var x -> Bool
flex provides an alternative Functor/Foldable/Traversable/Applicative/Monad hierarchy, defined in Flex.Math.Category (that I hinted at in yet another thread). It also includes profunctors, bifunctors & indexed functors/foldables/traversables, which makes defining optics straightforward (see Flex.Math.Optics for a lightweight, nearly drop-in replacement for lens).
Since this library is not (yet) on Hackage, to get started, clone flex into your project’s parent directory and add it to your project using the cabal.project stanza:
-- in the cabal.project file
packages:
.
../flex
-- in the .cabal file
build-depends:
..., flex
Documentation forthcoming.