Changes between Initial Version and Version 3 of Ticket #3005
 Timestamp:
 Apr 13, 2009 10:12:57 PM (8 years ago)
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 1 1 I have a module with a matrix type constructor: 2 2 {{{ 3 3 > data (Natural r, Natural c) => Matrix r c t = Matrix [[t]] deriving (Eq) 4 4 }}} 5 5 which uses typelevel naturals to provide dimension checking. 6 6 7 7 A type class for multiplication: 8 8 {{{ 9 9 > class Multiply a b where 10 10 > type Product a b 11 11 > times :: a > b > Product a b 12 12 }}} 13 13 and an instance for matrix multiplication: 14 14 {{{ 15 15 > instance (Natural a, Natural b, Natural c, Num t) => Multiply (Matrix a b t) (Matrix b c t) where 16 16 > type Product (Matrix a b t) (Matrix b c t) = Matrix a c t 17 17 > times m1 m2 = ... 18 18 }}} 19 19 All of this works really well, I get dimension checking (and inference), and lot of other goodies. 20 20 21 21 My request has to do with the following GHCi session: 22 22 {{{ 23 23 *Main> let a = matrix two two [[1,1],[2,6]] 24 24 *Main> :t a … … 27 27 a `times` a :: Product 28 28 (Matrix Two Two Integer) (Matrix Two Two Integer) 29 29 }}} 30 30 When a type function is fullyapplied, as Product is in this case, it would be nice if GHC could simplify it prior to display. 31 31 32 32 This would result in the following output for this example: 33 33 {{{ 34 34 :t a `times` a 35 35 a `times` a :: Matrix Two Two Integer 36 36 }}} 37 37 I have attached the files necessary to run this test case, although a simpler one could be constructed.