In an attempt to make a sane(r) alternative to Haskell's numeric type system, the devs of numeric-prelude slipped up and decided to name all of their type classes C
. Aside from making the docs totally confusing, this means that I have to fully qualify all uses of the typeclasses:
import qualified Algebra.Additive (C)
import qualified Algebra.Ring (C)
...
newtype Foo a = Foo a
instance (Algebra.Additive.C a) => Algebra.Additive.C (Foo a) where ...
myadd :: (Algebra.Additive.C a) => a -> a -> a
myadd a b = ...
Also, since NumericPrelude has finer grained typeclasses, I usually have to import several different NumericPrelude modules. I can simplify this a little by defining top-level constraint synonyms:
{-# LANGUAGE ConstraintKinds #-}
module NPSynonyms (Additive) where
import qualified Algebra.Additive (C)
type Additive a = (Algebra.Additive.C a)
which allows me to make sane functions:
myadd :: (Additive a) => a -> a -> a
myadd a b = ...
However, when I need to define an instance, I still have to (also) import the original NumericPrelude class:
{-# LANGUAGE ConstraintKinds #-}
import NPSynonyms
import Algebra.Additive (C)
newtype Foo a = Foo a
instance (Additive a) => Algebra.Additive.C (Foo a) where ...
So instead of making Additive
a type synonym with kind Constraint
, what I'd really like is to define a typeclass synonym for the typeclass Algebra.Additive.C
. Is there any way to do this in GHC 7.8, or is there any sane alternative?
T
and all of his classesC
. Everyone else knows it's terrible. – Carlnumeric-prelude
to fix the names – Gabriel Gonzalez