wiktorkuchta/django 0

The Web framework for perfectionists with deadlines.

wiktorkuchta/e-maxx-eng 0

Translation of into English

wiktorkuchta/rust 0

Empowering everyone to build reliable and efficient software.

wiktorkuchta/too-many-lists 0

Learn Rust by writing Entirely Too Many linked lists

issue openedhaskell/containers

Inconsistent usage of `==` and `=` equality in docs

While reading the docs for Data.Set, I noticed that in some places == is used and in some = is used. For example, the docs for powerSet:

Calculate the power set of a set: the set of all its subsets.

t `member` powerSet s == t `isSubsetOf` s


powerSet (fromList [1,2,3]) =
  fromList $ map fromList [[],[1],[1,2],[1,2,3],[1,3],[2],[2,3],[3]]

I guess that = should be used only if we can prove it from the definitions, and only if both sides are "internally" equal. For instance, we can disprove the above example easily:

Prelude Data.Set> putTree = putStrLn . showTree

Prelude Data.Set> putTree $ powerSet (fromList [1,2,3])
fromList [1,3]
+--fromList [1,2]
|  +--fromList [1]
|  |  +--fromList []
|  |  +--|
|  +--fromList [1,2,3]
+--fromList [2,3]
   +--fromList [2]
   +--fromList [3]

Prelude Data.Set> putTree $ fromList $ fromList [[],[1],[1,2],[1,2,3],[1,3],[2],[2,3],[3]]
fromList [1,2,3]
+--fromList [1]
|  +--fromList []
|  +--fromList [1,2]
+--fromList [2]
   +--fromList [1,3]
   +--fromList [2,3]
      +--fromList [3]

The examples for cartesianProduct and disjointUnion can be disproved similarly. From looking around, other modules like IntSet and Map modules also have this issue.

I suppose every nontrivial example/law equation with containers on both sides should use == instead of =.

created time in 2 months