anoma / juvix-stdlib

The Juvix standard library
https://anoma.github.io/juvix-stdlib/
11 stars 2 forks source link

Add instances for Functor, etc., for Set #129

Closed lukaszcz closed 1 month ago

lukaszcz commented 1 month ago
paulcadman commented 1 month ago

Haskell Set doesn't have a Functor instance.

The reason given is that the Functor law:

fmap (g . f) = fmap g . fmap f

can be violated. On the right duplicates are removed using f and then g . Whereas on the left duplicates are removed using g only.

I'm not sure if this is an issue for our Set implementation.

lukaszcz commented 1 month ago

Right, forgot about that. But we should have Set.map at least.

heueristik commented 1 month ago

I also have an implementation of isSubset. This should be in stdlib and probably should be improved.

    isSubset {A} {{Ord A}} (sub sup : Set A) : Bool := all (x in Set.toList sub) Set.isMember x sup;