[Haskell-cafe] Prolog-style patterns

Malcolm Wallace malcolm.wallace at me.com
Tue Apr 9 16:34:01 CEST 2013


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)




More information about the Haskell-Cafe mailing list