[Haskell-cafe] equations and patterns

mingli yuan mingli.yuan at gmail.com
Thu May 31 01:46:28 EDT 2007


Hi, buddies. I am a newbie on Haskell. Recently I want to implement a simple
Lattice in Haskell, but I met some difficulties.
Scrap of the code is as below, but I met syntax error:

>  class Lattice e where
>      join :: e -> e -> e
>      meet :: e -> e -> e
>
>      -- associative law
>      join x (join y z) = join (join x y) z
>      join (join x y) z = join x (join y z)

The main problem is that mathematic equations is bi-directed, but in Haskell
the pattern matching is only in one direction -
from left to right. And only variables and constructors could be occur in
the right side of the pattern matching.

Seems mathematic axioms and pattern matching are different things.

So how could I rewrite the equations to pattern matching? Which technique
should I learn?

Thanks for your help.

Regards,
Mingli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070531/3928b7a9/attachment.htm


More information about the Haskell-Cafe mailing list