
9 Feb
2006
9 Feb
'06
1:33 a.m.
Sometimes I'd like to use a smart constructor but have pattern matching as well. There has been talk elsewhere of allowing export of data constructors for /matching/ but not for /construction/: --------module One--------- data Picky a = Nil | One a picky x = if some_complex_thing x then One x else Nil --------module Two--------- f x = g $ picky x g Nil y = y g (One x) y = x h Nil = One True ----------------- I'd like for the function g to be fine and the function h to get a complaint like "error: no constructor 'One'" or, even better, "error: 'One' only works in pattern matching" Jim