metabrush/src/metabrushes/MetaBrush/Util.hs
2023-01-08 17:16:14 +01:00

21 lines
571 B
Haskell

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