meep-0.1.2.1: A silly container

Data.Meep

Description

A Map-like structure that contains up to one key-value pair

A Meep is strict in the key.

Meep k a is isomorphic to Maybe (k, a) with maybeing witnessing the isomorphism

Synopsis

# Documentation

data Meep k a Source #

A Meep from key k to value a

Instances

 Source # Methodsbimap :: (a -> b) -> (c -> d) -> Meep a c -> Meep b d #first :: (a -> b) -> Meep a c -> Meep b c #second :: (b -> c) -> Meep a b -> Meep a c # Source # Methodsbitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Meep a b -> f (Meep c d) # Source # Methodsbifold :: Monoid m => Meep m m -> m #bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Meep a b -> m #bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Meep a b -> c #bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Meep a b -> c # Source # Methods(<<.>>) :: Meep (a -> b) (c -> d) -> Meep a c -> Meep b d #(.>>) :: Meep a b -> Meep c d -> Meep c d #(<<.) :: Meep a b -> Meep c d -> Meep a b # FunctorWithIndex k (Meep k) Source # Methodsimap :: (k -> a -> b) -> Meep k a -> Meep k b #imapped :: (Indexable k p, Settable f) => p a (f b) -> Meep k a -> f (Meep k b) # Source # MethodsifoldMap :: Monoid m => (k -> a -> m) -> Meep k a -> m #ifolded :: (Indexable k p, Contravariant f, Applicative f) => p a (f a) -> Meep k a -> f (Meep k a) #ifoldr :: (k -> a -> b -> b) -> b -> Meep k a -> b #ifoldl :: (k -> b -> a -> b) -> b -> Meep k a -> b #ifoldr' :: (k -> a -> b -> b) -> b -> Meep k a -> b #ifoldl' :: (k -> b -> a -> b) -> b -> Meep k a -> b # Source # Methodsitraverse :: Applicative f => (k -> a -> f b) -> Meep k a -> f (Meep k b) #itraversed :: (Indexable k p, Applicative f) => p a (f b) -> Meep k a -> f (Meep k b) # Functor (Meep k) Source # Methodsfmap :: (a -> b) -> Meep k a -> Meep k b #(<\$) :: a -> Meep k b -> Meep k a # Foldable (Meep k) Source # Methodsfold :: Monoid m => Meep k m -> m #foldMap :: Monoid m => (a -> m) -> Meep k a -> m #foldr :: (a -> b -> b) -> b -> Meep k a -> b #foldr' :: (a -> b -> b) -> b -> Meep k a -> b #foldl :: (b -> a -> b) -> b -> Meep k a -> b #foldl' :: (b -> a -> b) -> b -> Meep k a -> b #foldr1 :: (a -> a -> a) -> Meep k a -> a #foldl1 :: (a -> a -> a) -> Meep k a -> a #toList :: Meep k a -> [a] #null :: Meep k a -> Bool #length :: Meep k a -> Int #elem :: Eq a => a -> Meep k a -> Bool #maximum :: Ord a => Meep k a -> a #minimum :: Ord a => Meep k a -> a #sum :: Num a => Meep k a -> a #product :: Num a => Meep k a -> a # Source # Methodstraverse :: Applicative f => (a -> f b) -> Meep k a -> f (Meep k b) #sequenceA :: Applicative f => Meep k (f a) -> f (Meep k a) #mapM :: Monad m => (a -> m b) -> Meep k a -> m (Meep k b) #sequence :: Monad m => Meep k (m a) -> m (Meep k a) # Eq k => Apply (Meep k) Source # Methods(<.>) :: Meep k (a -> b) -> Meep k a -> Meep k b #(.>) :: Meep k a -> Meep k b -> Meep k b #(<.) :: Meep k a -> Meep k b -> Meep k a # (Eq a, Eq k) => Eq (Meep k a) Source # Methods(==) :: Meep k a -> Meep k a -> Bool #(/=) :: Meep k a -> Meep k a -> Bool # (Data a, Data k) => Data (Meep k a) Source # Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Meep k a -> c (Meep k a) #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Meep k a) #toConstr :: Meep k a -> Constr #dataTypeOf :: Meep k a -> DataType #dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (Meep k a)) #dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Meep k a)) #gmapT :: (forall b. Data b => b -> b) -> Meep k a -> Meep k a #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Meep k a -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Meep k a -> r #gmapQ :: (forall d. Data d => d -> u) -> Meep k a -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> Meep k a -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> Meep k a -> m (Meep k a) #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Meep k a -> m (Meep k a) #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Meep k a -> m (Meep k a) # (Ord a, Ord k) => Ord (Meep k a) Source # Methodscompare :: Meep k a -> Meep k a -> Ordering #(<) :: Meep k a -> Meep k a -> Bool #(<=) :: Meep k a -> Meep k a -> Bool #(>) :: Meep k a -> Meep k a -> Bool #(>=) :: Meep k a -> Meep k a -> Bool #max :: Meep k a -> Meep k a -> Meep k a #min :: Meep k a -> Meep k a -> Meep k a # (Show k, Show a) => Show (Meep k a) Source # MethodsshowsPrec :: Int -> Meep k a -> ShowS #show :: Meep k a -> String #showList :: [Meep k a] -> ShowS # Generic (Meep k a) Source # Associated Typestype Rep (Meep k a) :: * -> * # Methodsfrom :: Meep k a -> Rep (Meep k a) x #to :: Rep (Meep k a) x -> Meep k a # (Eq k, Semigroup a) => Semigroup (Meep k a) Source # Meeps intersection Methods(<>) :: Meep k a -> Meep k a -> Meep k a #sconcat :: NonEmpty (Meep k a) -> Meep k a #stimes :: Integral b => b -> Meep k a -> Meep k a # Eq k => Ixed (Meep k a) Source # Methodsix :: Index (Meep k a) -> Traversal' (Meep k a) (IxValue (Meep k a)) # Eq k => At (Meep k a) Source # Methodsat :: Index (Meep k a) -> Lens' (Meep k a) (Maybe (IxValue (Meep k a))) # AsEmpty (Meep k a) Source # Methods_Empty :: Prism' (Meep k a) () # type Rep (Meep k a) Source # type Rep (Meep k a) = D1 (MetaData "Meep" "Data.Meep" "meep-0.1.2.1-LdRGDf28HjYJTMTR3vql0Y" False) ((:+:) (C1 (MetaCons "Empty" PrefixI False) U1) (C1 (MetaCons "Meep" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 k)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a))))) type Index (Meep k a) Source # type Index (Meep k a) = k type IxValue (Meep k a) Source # type IxValue (Meep k a) = a

empty :: Meep k a Source #

O(1). An empty Meep

singleton :: k -> a -> Meep k a Source #

O(1). A Meep with a single key-value pair

size :: Num b => Meep k a -> b Source #

O(1). The size of the Meep

>>> size empty
0

>>> size (singleton 4 "foo")
1


null :: Meep k a -> Bool Source #

O(1). The emptiness check for the Meep

>>> null empty
True

>>> null (singleton 4 "foo")
False


fromMaybe :: Maybe (k, a) -> Meep k a Source #

O(1). Build the Meep

fromMaybe ≡ view (from maybeing)


toMaybe :: Meep k a -> Maybe (k, a) Source #

O(1). Destroy the Meep

toMaybe ≡ view maybeing


maybeing :: Iso (Meep k v) (Meep k' v') (Maybe (k, v)) (Maybe (k', v')) Source #

O(1). A witness to

Meep k v ≅ Maybe (k, v)

>>> singleton 4 "foo" ^. maybeing
Just (4,"foo")

>>> Nothing ^. from maybeing
fromMaybe Nothing


intersection :: Eq k => Meep k a -> Meep k b -> Meep k a Source #

O(1). Intersection of two Meeps

intersection ≡ intersectionWith const


intersectionWith :: Eq k => (a -> b -> c) -> Meep k a -> Meep k b -> Meep k c Source #

O(1). Intersection of two Meeps with a combining function

>>> intersectionWith (+) (Meep "hello" 4) (Meep "hello" 7)
fromMaybe (Just ("hello",11))

>>> intersectionWith (+) (Meep "hello" 4) (Meep "bye" 7)
fromMaybe Nothing

>>> intersectionWith (+) Empty (Meep "hello" 7)
fromMaybe Nothing

intersectionWith f ≡ intersectionWithKey (const f)


intersectionWithKey :: Eq k => (k -> a -> b -> c) -> Meep k a -> Meep k b -> Meep k c Source #

O(1). Intersection of two Meeps with a combining function

keys :: Meep k a -> Maybe k Source #

O(1). Return all keys from the Meep

>>> keys (singleton 4 "foo")
Just 4

>>> keys empty
Nothing


elems :: Meep k a -> Maybe a Source #

O(1). Return all values from the Meep

>>> elems (singleton 4 "foo")
Just "foo"

>>> elems empty
Nothing