[Haskell] Re: View patterns in GHC: Request for feedback

Rene de Visser Rene_de_Visser at hotmail.com
Tue Jul 24 14:05:13 EDT 2007


"Claus Reinke" <claus.reinke at talk21.com> schrieb im Newsbeitrag 
news:004a01c7cde1$04b190f0$2e3f8351 at cr3lt...
>> though I'm extremely dubious about the utility of the "Maybe" patterns.
>
> actually, they are the main thing that interests me about view patterns!-)
>    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
Though I guess you would not object to:

size (unit -> Just ()) = 1
size (arrow -> Just (t1,t2)) = size t1 + size t2

?
Rene. 





More information about the Haskell mailing list