meep-0.1.1.0: A silly container

Safe HaskellSafe-Inferred
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 
Biapply Meep 
Bifunctor Meep 
Bifoldable Meep 
FunctorWithIndex k (Meep k) 
FoldableWithIndex k (Meep k) 
TraversableWithIndex k (Meep k) 
Functor (Meep k) 
Foldable (Meep k) 
Traversable (Meep k) 
(Eq k, Eq a) => Eq (Meep k a) 
(Data k, Data a) => Data (Meep k a) 
(Ord k, Ord a) => Ord (Meep k a) 
(Show k, Show a) => Show (Meep k a) 
Generic (Meep k a) 
(Eq k, Semigroup a) => Semigroup (Meep k a)

Meeps intersection

Eq k => Ixed (Meep k a) 
Eq k => At (Meep k a) 
AsEmpty (Meep k a) 
Typeable (* -> * -> *) Meep 
type Rep (Meep k a) 
type Index (Meep k a) = k 
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

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