In my Haskell code base, I have many functions that accept polymorphic arguments. These polymorphic arguments must all satisfy the same type set ( RealFloat a, Floating a, Real a, Show a, Ord a, Typeable a), and this set of classes must be present in function type annotations.
I currently manually write typeclass type annotations for each function, but it contains a verbose list of type repetitions repeating 30 times in my code base, and cumbersome to change the annotation of each type if I find out that I need to add another one to the list a type. I am wondering if there is a shorter way to share a common list of types.
I really want to define a "synonym for style type", for example typeclass NiceFloating a = RealFloat a, Floating a, Real a, Show a, Ord a, Typeable a, so I can just write NiceFloating a => ain all the annotations of my type.
If this function does not exist, maybe I can write a "master typeclass" that requires that the value satisfy each type class in the list of name types? But I do not want to write out all the operations, for example. Real, Show and Ord manually - is there any way around this?
source
share