meep-0.1.2.0: 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

 Bitraversable Meep Bifunctor Meep Bifoldable Meep Biapply Meep FunctorWithIndex k (Meep k) FoldableWithIndex k (Meep k) TraversableWithIndex k (Meep k) Functor (Meep k) Foldable (Meep k) Traversable (Meep k) Eq k => Apply (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) `Meep`s 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
```

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

O(1). Intersection of two `Meep`s

```intersection ≡ `intersectionWith` `const`
```

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

O(1). Intersection of two `Meep`s 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 `Meep`s 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
```