Zulip Chat Archive

Stream: general

Topic: Changing the functor typeclasses


Eric Wieser (Dec 23 2021 at 22:33):

(I split this to a new thread)

Yaël Dillies (Dec 23 2021 at 22:42):

How is it going?

Yaël Dillies (Dec 23 2021 at 22:44):

Something I noticed is that multiset does not have a docs#traversable instance because it does not commute with all applicative functors, but only all commutative applicative functors. data.multiset.functor currently contains the guts of what could be traversable multiset where it not for this problem. Should we thus change traversableto take in a specific functor?

Reid Barton (Dec 23 2021 at 23:05):

It's not really a problem. traversable is about things you can iterate over in a fixed order, multiset doesn't have an order, so there is no traversable multiset--that's just the way it is.

Eric Wieser (Sep 10 2025 at 01:16):

Eric Wieser said:

I explored this a little more in branch#eric-wieser/monad-universes, all the way up to applicative

For future reference, I was able to translate this to Lean 4 using default_instance:

Lean 4 version

which has test-case

#eval ([ULift.up.{32}] <*> [1, 2, 3])
#eval (ULift.up.{32} <$> [1, 2, 3])
#eval (#[ULift.up.{32}] <*> #[1, 2, 3])
#eval (ULift.up.{32} <$> #[1, 2, 3])
#eval (({ULift.up.{32}} : Finset _) <*> ({1, 2, 3} : Finset Nat))
#eval (ULift.up.{32} <$> ({1, 2, 3} : Finset Nat))

Last updated: Dec 20 2025 at 21:32 UTC