though I'm extremely dubious about the utility of the "Maybe" patterns.

actually, they are the main thing that interests me about view patterns!-)

it connects them to the existing work on first-class patterns (where combinators over Maybe patterns do the matching work, and view
patterns provide the syntax (a) for integrating Maybe patterns into
"dumb" patterns and (b) for binding the results of Maybe patterns to
pattern variables).

but then, i'd not so much use them as pretend views, but as abstract
deconstructors/observers in the unfoldr style. instead of constructing
real intermediate types, i'd have the implicit Maybe decide the match
and the returned subexpressions available in a tuple for further matching or binding. eg, the first example would become:

   type Typ

   unit :: Typ -> Maybe ()
   arrow :: Type -> Maybe (Typ,Typ)
size :: Typ -> Integer
   size (unit -> ()) = 1
   size (arrow -> (t1,t2)) = size t1 + size t2

closer to ordinary patterns, with the lowercase and the '->' hinting
that there is computation before matching (well, '=>', according to
the new proposal).

claus

_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to