Add `several`?
ekmett opened this issue · 1 comments
ekmett commented
import Data.Functor.Contravariant
import Data.Functor.Contravariant.Divisible
newtype Str a = Str { runStr :: Either (Either () a) (Str a, Str a) }
instance Monoid (Str a) where
mempty = Str (Left (Left ()))
mappend a b = Str (Right (a,b))
unit :: a -> Str a
unit a = Str (Left (Right a))
several :: (Decidable f, Foldable g) => f a -> f (g a)
several f = contramap (foldMap unit) go where
go = choose runStr (chosen conquer f) (divided go go)
ekmett commented
lens
could also pick up
severalOf :: Decidable f => Getting (Str a) s a -> f a -> f s