[Haskell-cafe] basic field questions

Neil Mitchell ndmitchell at gmail.com
Thu Jan 25 05:46:40 EST 2007


> sq = squishiness $ Table {colour = Black, weight=1, height= 2}
> main = putStr $ show sq

squishiness is just translated to:

squishiness :: Furniture -> Double
squishiness (Chair _ _ x) = x
squishiness _ = error "doh"

> main: No match in record selector Main.squishiness

Hence this is a pattern match error (runtime), not a type error
(compile time). There are people working on extending the types to
catch this kind of thing, and also people working on static checkers
to catch patter match errors [1] and people working on annotations to
get this kind of thing [2].

It's not a solved problem yet, but certainly I have a demo checker
that would have spotted this easily.



[1] http://www-users.cs.york.ac.uk/~ndm/projects/catch.php

[2] http://www.cl.cam.ac.uk/~nx200/research/escH-hw.ps

More information about the Haskell-Cafe mailing list