Why is there no `SetK.applicative()` similar to `L...
# arrow
r
Why is there no
SetK.applicative()
similar to
ListK.applicative()
?
i
Sounds valid
I have to correct myself
r
Set can’t form a lawful functor and all Applicative are Functor. Since a
Set
can’t guarantee an order of iteration it could not guarantee the identity and composition laws of functor. It could not guarantee for example that mapping over the identity returns the same value if each time you iterate you get a different order.
👍 1
Other collections that can guarantee order can form lawful Functors.
i
r
That is not part of cats but alleycats which is the lib for unlawful stuff
👌🏽 2
i
ohh
r
@Ryan Benasutti you can implement an unlawful applicative instance ad hoc for set but Arrow will not include one ever because it would yield impure non deterministic results
it will also most likely not pass the functor laws and if it did it would be relying in the internal impl of the default Set of the std lib which is also dangerous because if it changes it will break. AFAIK Set in kotlin guarantees no order and if it did it would have Functor and Applicative.