ryani.spam at gmail.com
Sat Sep 13 14:47:46 EDT 2008
On Sat, Sep 13, 2008 at 11:19 AM, Stephan Friedrichs
<deduktionstheorem at web.de> wrote:
> data View
> = Empty
> | Cons a (SomeDataStructure a)
> A good example for this is Data.Sequence. My question is: Why is this
> not expressed in terms of Maybe?
> view :: SomeDataStructure a -> Maybe (a, SomeDataStructure a)
I think the usual reason this is done is because it is clearer to
read. Since Maybe is so generally useful, when you read code that
uses it, you have to figure out what use it is being put towards.
"What does Nothing mean? What does Just (a,b) mean?" are the kinds of
questions that go through your head, and they distract you from the
problem at hand.
On the other hand, reading code that uses the View type, it is
immediately clear what Empty and Cons mean. But you're right, Maybe
has a lot of useful helper functions and instances.
More information about the Haskell-Cafe