Changes between Initial Version and Version 3 of Ticket #3005


Ignore:
Timestamp:
Apr 13, 2009 10:12:57 PM (6 years ago)
Author:
igloo
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #3005

    • Property Owner set to chak
    • Property Cc jpm@… added
    • Property Difficulty changed from to Unknown
  • Ticket #3005 – Description

    initial v3  
    11I have a module with a matrix type constructor:
    2 
     2{{{
    33> data (Natural r, Natural c) => Matrix r c t = Matrix [[t]] deriving (Eq)
    4 
     4}}}
    55which uses type-level naturals to provide dimension checking.
    66
    77A type class for multiplication:
    8 
     8{{{
    99> class Multiply a b where
    1010>  type Product a b
    1111>  times :: a -> b -> Product a b
    12 
     12}}}
    1313and an instance for matrix multiplication:
    14 
     14{{{
    1515> instance (Natural a, Natural b, Natural c, Num t) => Multiply (Matrix a b t) (Matrix b c t) where
    1616>  type Product (Matrix a b t) (Matrix b c t) = Matrix a c t
    1717>  times m1 m2 = ...
    18 
     18}}}
    1919All of this works really well, I get dimension checking (and inference), and lot of other goodies.
    2020
    2121My request has to do with the following GHCi session:
    22 
     22{{{
    2323*Main> let a = matrix two two [[1,1],[2,6]]
    2424*Main> :t a
     
    2727a `times` a :: Product
    2828                 (Matrix Two Two Integer) (Matrix Two Two Integer)
    29 
     29}}}
    3030When a type function is fully-applied, as Product is in this case, it would be nice if GHC could simplify it prior to display.
    3131
    3232This would result in the following output for this example:
    33 
     33{{{
    3434:t a `times` a
    3535a `times` a :: Matrix Two Two Integer
    36 
     36}}}
    3737I have attached the files necessary to run this test case, although a simpler one could be constructed.