anoma / juvix-containers

Immutable container types for Juvix
1 stars 3 forks source link

Add `Foldable` and `Functor` instances for containers #19

Open lukaszcz opened 3 months ago

lukaszcz commented 3 months ago

Now that we have Foldable and Functor traits, we could use for and map directly with the containers without converting them to/from lists.

lukaszcz commented 3 months ago

I see Foldable is implemented for AVLTree by converting to list first. This conversion is unnecessary overhead (and it's significant with many traversals).

There seem to be no implementations for Functor or Foldable for Map.

@heueristik Since Set is an alias for AVLTree writing for (acc := acc0) (x in set) {..} just works without converting set to list manually first (it should work with the most recent version of the containers library at least)