<html><body>Hello list,<br><br>As my first post. I'd like to open a can of worms that I sure has been opened before. That is record syntax.<br><br>As we all know, there are some type safety problems with our current record syntax. The most obvious is that this compiles without even giving you a warning:<br><br>>data MyData = <br>> A {a::Int,<br>> b::Int} |<br>> B {c::Int}<br><br>>foo :: MyData -> Int<br>>foo a@A{} = c a<br><br>>main :: IO ()<br>>main = print $ foo (A 1 2)<br><br>This compiles, then crashes at run time. Rediculus, why didn't the glorious GHC catch this? This is not some ambigious scenario... One way I found to improve type checking is this:<br><br>>data MyData = A A' | B B'<br><br>>data A' = A'{a::Int,<br>> b::Int}<br>>data B' = B'{c::Int}<br><br>>foo :: MyData -> Int<br>>foo (A a) = c a <br><br>>main :: IO ()<br>>main = print $ foo (A (A' 1 2))<br><br>This doesn't compile anymore because a :: A' and c :: B' -> X<br><br>It seems like the later method is simply better. Better type checking = fewer runtime errors(I actually ran into a crash in a real project because of this lack of proper type checking...).<br><br>Can we have a nice sugar for doing the later method?<br><br>Thank you for your time,<br>Timothy<br></body></html>