Alias for member
Alias for Foldable[ISet].index
The Functor
composition law only holds for functions that preserve
equivalence, i.e.
The Functor
composition law only holds for functions that preserve
equivalence, i.e. for functions f
such that
Order[A].equal(a1, a2)
⇒ Order[B].equal(f(a1), f(a2))
In the case when the equivalence implied by Order[A]
is in fact
_equality_, i.e. the finest equivalence, i.e. satisfying the
_substitution property_ (which is the above property quantified over
all f
, see Wikipedia page on Equality),
the requirement holds for all f
by definition.
When Order
instances are viewed as "mere" equivalences (as opposed
to equalities), we can loosely say that ISet
is an (endo-)functor
in the category _Equiv_ of sets with an equivalence relation (where
the morphishms are equivalence-preserving functions, i.e. exactly the
functions satisfying the above requirement). By contrast, Functor
instances are functors in the _Scala_ category, whose morphisms are
arbitrary functions, including the ones that don't preserve equivalence.
Note: this is not able to implement Functor
due to the Order
constraint on the destination type,
however it still is a functor in the mathematical sense.
Documentation as copied from the Haskell source:
-- | /O(n*log n)/. -- @'map' f s@ is the set obtained by applying @f@ to each element of @s@. -- -- It's worth noting that the size of the result may be smaller if, -- for some @(x,y)@, @x \/= y && f x == f y@
https://github.com/haskell/containers/blob/v0.5.7.1/Data/Set/Base.hs
https://hackage.haskell.org/package/containers-0.5.7.1/docs/Data-Set.html