module MetaBrush.Util ( traverseMaybe , Exists(..) ) where -- containers import Data.Sequence ( Seq(..) ) -------------------------------------------------------------------------------- traverseMaybe :: Applicative f => ( a -> f ( Maybe b ) ) -> Seq a -> f ( Seq b ) traverseMaybe _ Empty = pure Empty traverseMaybe f ( a :<| as ) = ( \ case { Nothing -> id; Just b -> ( b :<| ) } ) <$> f a <*> traverseMaybe f as -------------------------------------------------------------------------------- data Exists c where Exists :: c a => a -> Exists c