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