Normalize fully-applied type functions prior to display
|Reported by:||dmcclean||Owned by:||chak|
|Type of failure:||None/Unknown||Test Case:|
|Related Tickets:||Differential Rev(s):|
Description (last modified by )
I have a module with a matrix type constructor:
> data (Natural r, Natural c) => Matrix r c t = Matrix [[t]] deriving (Eq)
which uses type-level naturals to provide dimension checking.
A type class for multiplication:
> class Multiply a b where > type Product a b > times :: a -> b -> Product a b
and an instance for matrix multiplication:
> instance (Natural a, Natural b, Natural c, Num t) => Multiply (Matrix a b t) (Matrix b c t) where > type Product (Matrix a b t) (Matrix b c t) = Matrix a c t > times m1 m2 = ...
All of this works really well, I get dimension checking (and inference), and lot of other goodies.
My request has to do with the following GHCi session:
*Main> let a = matrix two two [[1,1],[2,6]] *Main> :t a a :: Matrix Two Two Integer *Main> :t a `times` a a `times` a :: Product (Matrix Two Two Integer) (Matrix Two Two Integer)
When a type function is fully-applied, as Product is in this case, it would be nice if GHC could simplify it prior to display.
This would result in the following output for this example:
:t a `times` a a `times` a :: Matrix Two Two Integer
I have attached the files necessary to run this test case, although a simpler one could be constructed.