In message <[EMAIL PROTECTED] com>, [EMAIL PROTECTED] writes: >it is nice to use 'maybe', 'either' functions. However, with data types >with more than 2 constructors, using such function tends to be tedious than >pattern match, where, you can pick specific constructors of interest. > >And in order to use pattern match, I have to expose my constructors.
You don't necessarily need to expose the constructors even in that case. Often you can expose functions that return 'Maybe a' for some suitably chosen 'a' instead of the constructor itself. Then you can pattern match with e.g. the following syntax: f x | Just(y) <- matchZ x = y + 1 And the Maybe monad works beautifully for combining such functions into larger pattern matchers. The point with having abstraction is to actually expose only higher level operations. Of course, this doesn't negate any other reasons you might have for exposing the constructors [e.g. if the data type is used to represent an interface], but if you want to build abstract data types, those should be at higher level of abstraction than the concrete types. -- Esa Pulkkinen _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell