mirror of
https://gitlab.com/sheaf/metabrush.git
synced 2024-11-06 07:13:37 +00:00
21 lines
571 B
Haskell
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
|