[Haskell-cafe] Prolog-style patterns
dav.vire+haskell at gmail.com
Mon Apr 8 15:18:57 CEST 2013
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.
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
> 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 :)
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe