On Oct 11, 2008, at 2:54 PM, Bit Connor wrote:
Smart constructors are nice but if your module doesn't also export the
regular constructor then you can't pattern match against it.
It would be cool if there was a way to export constructors from a
module, but only for use in pattern matching and not constructing new
values.
I suppose you could make a new data type to pattern match against. For
example, say you have
data Foo A B = <hidden constructors>
foo :: A -> B -> Foo A B -- smart constructor
You could introduce and export
data FooView = Foo A B | <other possible deconstructions>
fooView :: Foo A B -> FooView A B
You could even redefine the smart constructor as
foo : FooView A B -> Foo A B
... if you wanted.
- Jake
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe