[Haskell-cafe] Prolog-style patterns

David Virebayre dav.vire+haskell at gmail.com
Mon Apr 8 15:18:57 CEST 2013


Hi Jan,

On one hand, I've never really needed this.
On the other hand, it looks like a nice syntaxic sugar addition, so if you
implemented this I would probably give it a try.

David.


2013/4/8 Jan Stolarek <jan.stolarek at p.lodz.pl>

> > You can achieve something similar with the ViewPatterns language
> > extension.
> >
> > member _ [] = False
> > member x (((x ==) -> True) : _) = True
> > member x (_ : xs) = member x xs
> Hi Tillmann,
>
> there are a couple of ways to achieve this in Haskell, for example using
> guards:
>
> member :: Eq a => a -> [a] -> Bool
> member _ []             = False
> member y (x:_) | x == y = True
> member y (_:xs)         = member y xs
>
> The goal of my proposal is to provide a concise syntax, whereas
> ViewPatterns are very verbose and
> guards are slightly verbose. I want something simple and something that is
> very intuitive if
> you've programmed in Prolog :)
>
> Janek
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130408/892902ab/attachment.htm>


More information about the Haskell-Cafe mailing list