[Haskell-cafe] Prolog-style patterns

Roman Cheplyaka roma at ro-che.info
Tue Apr 9 16:43:07 CEST 2013


* Malcolm Wallace <malcolm.wallace at me.com> [2013-04-09 15:34:01+0100]
> 
> On 9 Apr 2013, at 14:46, Sturdy, Ian wrote:
> 
> > As far as the use of Eq goes, Eq is already enshrined in pattern matching by pattern matching against literals.
> 
> Not true.  Pattern-matching literals explicitly avoids any use of Eq.  Demonstration:
> 
> data Foo = Foo | Bar
> instance Eq Foo where
>     _ == _ = True
> 
> isFoo Foo = True
> isFoo Bar = False
> 
> main = do print (isFoo Bar)
>           print (Foo==Bar)

I think he meant numeric literals.

Roman



More information about the Haskell-Cafe mailing list