Overloadable list type notation
Edward Kmett
ekmett at gmail.com
Tue Feb 17 18:24:38 UTC 2015
On Tue, Feb 17, 2015 at 1:14 PM, Alexander Berntsen <alexander at plaimi.net>
wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> On 17/02/15 05:30, Greg Weber wrote:
> > I had an idea whose goal is to ease people into Foldable,
> > Traversable, etc. There could be a notation that shows the
> > generalization that is occurring.
> >
> > map :: Functor [_] => (a -> b) -> [a] -> [b]
> >
> > This means that the syntax for the list type is now syntax for the
> > variable created by the Functor constraint.
> I don't know how useful this is by itself.
>
> What I *really* want is list-style syntax sugar for pattern matching. I.e.
>
> f = \xs -> case xs of
> [] -> foo
> [x] -> bar x
> [x:y] -> fu x y
> (x:xs) -> baz x xs
>
>
The existing IsList machinery gets you the [], [x], and [x,y] cases, but
not (x:xs).
-Edward
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20150217/b90c53f6/attachment.html>
More information about the Libraries
mailing list