[Haskell] Re: View patterns in GHC: Request for feedback
ajb at spamcop.net
ajb at spamcop.net
Tue Jul 24 20:16:53 EDT 2007
G'day all.
"Claus Reinke" <claus.reinke at talk21.com> schrieb im Newsbeitrag
news:004a01c7cde1$04b190f0$2e3f8351 at cr3lt...
> > type Typ
> >
> > unit :: Typ -> Maybe ()
> > arrow :: Type -> Maybe (Typ,Typ)
> > size :: Typ -> Integer
> > size (unit -> ()) = 1
> > size (arrow -> (t1,t2)) = size t1 + size t2
The whole point of a view is that you make views that are semantically
useful.
data UsefulView = Unit | Arrow Type Type
usefulView :: Type -> UsefulView
size :: Type -> Integer
size (usefulView -> Unit) = 1
size (usefulView -> Arrow t1 t2) = size t1 + size t2
Cheers,
Andrew Bromage
More information about the Haskell
mailing list