
4 May
2006
4 May
'06
9:20 a.m.
I was experimenting with records this morning and discovered a slight oddity... data Rec = RecA { a :: Int } | RecB { a :: Int, b :: Bool } deriving Show main :: IO () main = do print (b (RecB { a = 1, b = True })) -- Works print (b (RecA { a = 1 })) -- Doesn't Of course extracting "b" from a record constructed with "RecA" is illegal, but the compiler did not warn against it (ghc -W). I was expecting a warning similar to non-exhaustive pattern matching. Are records with optional fields really type safe? -Tom