meep-0.1.2.2: A silly container

Safe HaskellSafe
LanguageHaskell2010

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
Bitraversable Meep Source # 
Instance details

Defined in Data.Meep

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Meep a b -> f (Meep c d) #

Bifoldable Meep Source # 
Instance details

Defined in Data.Meep

Methods

bifold :: 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 #

Bifunctor Meep Source # 
Instance details

Defined in Data.Meep

Methods

bimap :: (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 #

Biapply Meep Source # 
Instance details

Defined in Data.Meep

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 # 
Instance details

Defined in Data.Meep

Methods

imap :: (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) #

FoldableWithIndex k (Meep k) Source # 
Instance details

Defined in Data.Meep

Methods

ifoldMap :: 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 #

TraversableWithIndex k (Meep k) Source # 
Instance details

Defined in Data.Meep

Methods

itraverse :: 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 # 
Instance details

Defined in Data.Meep

Methods

fmap :: (a -> b) -> Meep k a -> Meep k b #

(<$) :: a -> Meep k b -> Meep k a #

Foldable (Meep k) Source # 
Instance details

Defined in Data.Meep

Methods

fold :: 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 #

Traversable (Meep k) Source # 
Instance details

Defined in Data.Meep

Methods

traverse :: 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 # 
Instance details

Defined in Data.Meep

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 #

liftF2 :: (a -> b -> c) -> Meep k a -> Meep k b -> Meep k c #

(Eq k, Eq a) => Eq (Meep k a) Source # 
Instance details

Defined in Data.Meep

Methods

(==) :: Meep k a -> Meep k a -> Bool #

(/=) :: Meep k a -> Meep k a -> Bool #

(Data k, Data a) => Data (Meep k a) Source # 
Instance details

Defined in Data.Meep

Methods

gfoldl :: (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 k, Ord a) => Ord (Meep k a) Source # 
Instance details

Defined in Data.Meep

Methods

compare :: 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 # 
Instance details

Defined in Data.Meep

Methods

showsPrec :: Int -> Meep k a -> ShowS #

show :: Meep k a -> String #

showList :: [Meep k a] -> ShowS #

Generic (Meep k a) Source # 
Instance details

Defined in Data.Meep

Associated Types

type Rep (Meep k a) :: * -> * #

Methods

from :: 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

Instance details

Defined in Data.Meep

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 # 
Instance details

Defined in Data.Meep

Methods

ix :: Index (Meep k a) -> Traversal' (Meep k a) (IxValue (Meep k a)) #

Eq k => At (Meep k a) Source # 
Instance details

Defined in Data.Meep

Methods

at :: Index (Meep k a) -> Lens' (Meep k a) (Maybe (IxValue (Meep k a))) #

AsEmpty (Meep k a) Source # 
Instance details

Defined in Data.Meep

Methods

_Empty :: Prism' (Meep k a) () #

type Rep (Meep k a) Source # 
Instance details

Defined in Data.Meep

type Rep (Meep k a) = D1 (MetaData "Meep" "Data.Meep" "meep-0.1.2.2-APY5BbX8ClaA3Myq1d9LWV" False) (C1 (MetaCons "Empty" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "Meep" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 k) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))
type Index (Meep k a) Source # 
Instance details

Defined in Data.Meep

type Index (Meep k a) = k
type IxValue (Meep k a) Source # 
Instance details

Defined in Data.Meep

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