4 ms·
Why can't you define a set monad? The first definition I can think of is making behave like Haskell's list monad? That is to say that "xs ==> (\x -> f x)" Woul
by gizmo686 13y ago
Why can't you define a set monad? The first definition I can think of is making behave like Haskell's list monad?
That is to say that "xs ==> (\x -> f x)" Would take every element in the set "xs", pass each of them into f, and union the results into a single set.
- velis_vel 13y agoSet basically has an Ord constraint on the type of things you have a Set of since most of the functions on it have an Ord a constraint, and Monads can't be constrained in what types they wrap. This is also why it's not a Functor; you can define setMap :: (Ord a, Ord b) => (a -> b) -> Set a -> Set b but that's still more restricted than fmap.
- elliotlai 13y agoBecause a monad is also a functor, but a set failed to be a functor.