th-desugar-1.15: Functions to desugar Template Haskell

Copyright | (C) 2016-2018 Daniel Wagner 2019 Ryan Scott
License | BSD-style (see LICENSE)
Maintainer | Ryan Scott
Stability | experimental
Portability | non-portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Language.Haskell.TH.Desugar.OMap.Strict

Contents

- Trivial maps
- Insertion
- Deletion
- Query
- Indexing
- List conversions
- `Map` conversion

Description

An `OMap` behaves much like a `Map`, with all the same asymptotics, but also remembers the order that keys were inserted.

This module offers a simplified version of the Data.Map.Ordered.Strict API that assumes left-biased indices everywhere and uses a different `Semigroup` instance (the one in this module uses `(`<>`) = `union``) and `Monoid` instance (the one in this module uses ``mappend` = `union``).

Synopsis

- newtype OMap k v = OMap (Bias L (OMap k v))
- empty :: forall k v. OMap k v
- singleton :: k -> v -> OMap k v
- insertPre :: Ord k => k -> v -> OMap k v -> OMap k v
- insertPost :: Ord k => OMap k v -> k -> v -> OMap k v
- union :: forall k v. Ord k => OMap k v -> OMap k v -> OMap k v
- unionWithKey :: Ord k => (k -> v -> v -> v) -> OMap k v -> OMap k v -> OMap k v
- delete :: forall k v. Ord k => k -> OMap k v -> OMap k v
- filterWithKey :: Ord k => (k -> v -> Bool) -> OMap k v -> OMap k v
- (\\) :: forall k v v'. Ord k => OMap k v -> OMap k v' -> OMap k v
- intersection :: forall k v v'. Ord k => OMap k v -> OMap k v' -> OMap k v
- intersectionWithKey :: Ord k => (k -> v -> v' -> v'') -> OMap k v -> OMap k v' -> OMap k v''
- null :: forall k v. OMap k v -> Bool
- size :: forall k v. OMap k v -> Int
- member :: forall k v. Ord k => k -> OMap k v -> Bool
- notMember :: forall k v. Ord k => k -> OMap k v -> Bool
- lookup :: forall k v. Ord k => k -> OMap k v -> Maybe v
- type Index = Int
- lookupIndex :: forall k v. Ord k => k -> OMap k v -> Maybe Index
- lookupAt :: forall k v. Index -> OMap k v -> Maybe (k, v)
- fromList :: Ord k => [(k, v)] -> OMap k v
- assocs :: forall k v. OMap k v -> [(k, v)]
- toAscList :: forall k v. OMap k v -> [(k, v)]
- toMap :: forall k v. OMap k v -> Map k v

# Documentation

newtype OMap k v Source #

An ordered map whose `insertPre`, `insertPost`, `intersection`, `intersectionWithKey`, `union`, and `unionWithKey` operations are biased towards leftmost indices when when breaking ties between keys.

Constructors

OMap (Bias L (OMap k v)) |

#### Instances

Instances details

Foldable (OMap k) Source # |

Instance details

Defined in Language.Haskell.TH.Desugar.OMap

Methods

fold :: Monoid m => OMap k m -> m Source #

foldMap :: Monoid m => (a -> m) -> OMap k a -> m Source #

foldMap' :: Monoid m => (a -> m) -> OMap k a -> m Source #

foldr :: (a -> b -> b) -> b -> OMap k a -> b Source #

foldr' :: (a -> b -> b) -> b -> OMap k a -> b Source #

foldl :: (b -> a -> b) -> b -> OMap k a -> b Source #

foldl' :: (b -> a -> b) -> b -> OMap k a -> b Source #

foldr1 :: (a -> a -> a) -> OMap k a -> a Source #

foldl1 :: (a -> a -> a) -> OMap k a -> a Source #

toList :: OMap k a -> [a] Source #

null :: OMap k a -> Bool Source #

length :: OMap k a -> Int Source #

elem :: Eq a => a -> OMap k a -> Bool Source #

maximum :: Ord a => OMap k a -> a Source #

minimum :: Ord a => OMap k a -> a Source #

sum :: Num a => OMap k a -> a Source #

product :: Num a => OMap k a -> a Source #

Ord k => Traversable (OMap k) Source # |
Instance details Defined in Language.Haskell.TH.Desugar.OMap Methods traverse :: Applicative f => (a -> f b) -> OMap k a -> f (OMap k b) Source # sequenceA :: Applicative f => OMap k (f a) -> f (OMap k a) Source # mapM :: Monad m => (a -> m b) -> OMap k a -> m (OMap k b) Source # sequence :: Monad m => OMap k (m a) -> m (OMap k a) Source #
Functor (OMap k) Source # |
Instance details Defined in Language.Haskell.TH.Desugar.OMap Methods fmap :: (a -> b) -> OMap k a -> OMap k b Source # (<$) :: a -> OMap k b -> OMap k a Source #
(Data k, Data v, Ord k) => Data (OMap k v) Source # |

Instance details

Defined in Language.Haskell.TH.Desugar.OMap

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> OMap k v -> c (OMap k v) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (OMap k v) Source #

toConstr :: OMap k v -> Constr Source #

dataTypeOf :: OMap k v -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (OMap k v)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (OMap k v)) Source #

gmapT :: (forall b. Data b => b -> b) -> OMap k v -> OMap k v Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OMap k v -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OMap k v -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> OMap k v -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> OMap k v -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> OMap k v -> m (OMap k v) Source #

Ord k => Monoid (OMap k v) Source # |
Instance details Defined in Language.Haskell.TH.Desugar.OMap Methods mempty :: OMap k v Source # mappend :: OMap k v -> OMap k v -> OMap k v Source # mconcat :: [OMap k v] -> OMap k v Source #
Ord k => Semigroup (OMap k v) Source # |
Instance details Defined in Language.Haskell.TH.Desugar.OMap Methods (<>) :: OMap k v -> OMap k v -> OMap k v Source # sconcat :: NonEmpty (OMap k v) -> OMap k v Source # stimes :: Integral b => b -> OMap k v -> OMap k v Source #
(Ord k, Read k, Read v) => Read (OMap k v) Source # |
Instance details Defined in Language.Haskell.TH.Desugar.OMap Methods readsPrec :: Int -> ReadS (OMap k v) Source # readList :: ReadS [OMap k v] Source # readPrec :: ReadPrec (OMap k v) Source # readListPrec :: ReadPrec [OMap k v] Source #
(Show k, Show v) => Show (OMap k v) Source # |
Instance details Defined in Language.Haskell.TH.Desugar.OMap Methods showsPrec :: Int -> OMap k v -> ShowS Source # show :: OMap k v -> String Source # showList :: [OMap k v] -> ShowS Source #
(Eq k, Eq v) => Eq (OMap k v) Source # |
Instance details Defined in Language.Haskell.TH.Desugar.OMap Methods (==) :: OMap k v -> OMap k v -> Bool Source # (/=) :: OMap k v -> OMap k v -> Bool Source #
(Ord k, Ord v) => Ord (OMap k v) Source # |

Instance details

Defined in Language.Haskell.TH.Desugar.OMap

Methods

compare :: OMap k v -> OMap k v -> Ordering Source #

(<) :: OMap k v -> OMap k v -> Bool Source #

(<=) :: OMap k v -> OMap k v -> Bool Source #

(>) :: OMap k v -> OMap k v -> Bool Source #

(>=) :: OMap k v -> OMap k v -> Bool Source #

max :: OMap k v -> OMap k v -> OMap k v Source #

min :: OMap k v -> OMap k v -> OMap k v Source #

# Trivial maps

empty :: forall k v. OMap k v Source #

singleton :: k -> v -> OMap k v Source #

# Insertion

insertPre :: Ord k => k -> v -> OMap k v -> OMap k v Source #

The value's index will be lower than the indices of the values in the `OSet`.

insertPost :: Ord k => OMap k v -> k -> v -> OMap k v Source #

The value's index will be higher than the indices of the values in the `OSet`.

union :: forall k v. Ord k => OMap k v -> OMap k v -> OMap k v Source #

unionWithKey :: Ord k => (k -> v -> v -> v) -> OMap k v -> OMap k v -> OMap k v Source #

# Deletion

delete :: forall k v. Ord k => k -> OMap k v -> OMap k v Source #

filterWithKey :: Ord k => (k -> v -> Bool) -> OMap k v -> OMap k v Source #

(\\) :: forall k v v'. Ord k => OMap k v -> OMap k v' -> OMap k v Source #

intersection :: forall k v v'. Ord k => OMap k v -> OMap k v' -> OMap k v Source #

intersectionWithKey :: Ord k => (k -> v -> v' -> v'') -> OMap k v -> OMap k v' -> OMap k v'' Source #

# Query

null :: forall k v. OMap k v -> Bool Source #

size :: forall k v. OMap k v -> Int Source #

member :: forall k v. Ord k => k -> OMap k v -> Bool Source #

notMember :: forall k v. Ord k => k -> OMap k v -> Bool Source #

lookup :: forall k v. Ord k => k -> OMap k v -> Maybe v Source #

# Indexing

type Index = Int Source #

A 0-based index, much like the indices used by lists' `!!` operation. All indices are with respect to insertion order.

lookupIndex :: forall k v. Ord k => k -> OMap k v -> Maybe Index Source #

lookupAt :: forall k v. Index -> OMap k v -> Maybe (k, v) Source #

# List conversions

fromList :: Ord k => [(k, v)] -> OMap k v Source #

assocs :: forall k v. OMap k v -> [(k, v)] Source #

toAscList :: forall k v. OMap k v -> [(k, v)] Source #

# `Map` conversion

toMap :: forall k v. OMap k v -> Map k v Source #