exported pattern matching

Jim Apple jbapple+haskell-prime at gmail.com
Thu Feb 9 01:33:59 EST 2006


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


More information about the Haskell-prime mailing list