reduceWith getMonadSum
>>> msumOf both ("hello","world") "helloworld"
>>> msumOf each (Nothing, Just "hello", Nothing) Just "hello"
msum ≡ msumOf folded
msumOf :: MonadPlus m => Getter s (m a) -> s -> m a msumOf :: MonadPlus m => Fold s (m a) -> s -> m a msumOf :: MonadPlus m => Lens' s (m a) -> s -> m a msumOf :: MonadPlus m => Iso' s (m a) -> s -> m a msumOf :: MonadPlus m => Traversal' s (m a) -> s -> m a msumOf :: MonadPlus m => Prism' s (m a) -> s -> m a
preview l (review l b) ≡ Just bbreaks with
>>> let badPrism :: Prism' (Maybe Char) (Either Char Char); badPrism = prismSum _Just _Just >>> preview badPrism (review badPrism (Right 'x')) Just (Left 'x')We put in Right value, but get back Left. Are you looking for without?
type Animal = SumType '[Owl, Cat, Toad] let someAnimal = ... :: Animal fromSumType (Proxy :: Proxy 0) someAnimal :: Maybe Owl fromSumType (Proxy :: Proxy 1) someAnimal :: Maybe Cat fromSumType (Proxy :: Proxy 2) someAnimal :: Maybe Toad -- Compile-time error -- fromSumType (Proxy :: Proxy 3) someAnimal