haskellari / lattices

Fine-grained lattice primitives for Haskell
BSD 3-Clause "New" or "Revised" License
35 stars 15 forks source link

two synonymous methods is confusing and leads to bugs #13

Closed imz closed 9 years ago

imz commented 9 years ago

Instead of having two synonymous methods:

class JoinSemiLattice a where
    (\/) :: a -> a -> a
    (\/) = join

    join :: a -> a -> a
    join = (\/)

it's better to have a top-level synonym, say:

class JoinSemiLattice a where
    join :: a -> a -> a

(\/) :: a -> a -> a
(\/) = join

Two synonymous methods is a sitiation leading to bugs: there is nothing that would prevent to write two differnt implementations for them in an (buggy) intance, and then all the code relying on them being synonymous will go crazy. (And that's anyway a crazy situation, because there is no sense in two different implementations for the two methods.)

The same holds for other analogous classes in this packages.

imz commented 9 years ago

And the statement:

minimal complete definition: nothing

is wrong. In your case it's:

minimal complete definition: either join or \/.

(Just another illustration of the bugginess of the current situation.)

phadej commented 9 years ago

Seems that I had too strict CPP ifdef for Minimal pragma, relaxed it to work on 7.8 too (as it does). Also added deprecated pragmas for meet and join, as their use is now discouraged; prefer infix versions. They are there for backwards compatibility though. (join is confusing, it's Monad method)

Uploaded lattices-1.4.1

phadej commented 9 years ago

And thanks for spotting the error!

imz commented 9 years ago

You are welcome!

Are there plans to remove the deprecated names in future versions? I feel like it would be cleaner if they are removed.

phadej commented 9 years ago

Yes, but they are introduced in 1.4, so we have to wait a bit.