th-desugar-1.10: Functions to desugar Template Haskell

Copyright(C) 2016-2018 Daniel Wagner 2019 Ryan Scott
LicenseBSD-style (see LICENSE)
MaintainerRyan Scott
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Language.Haskell.TH.Desugar.OMap

Contents

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

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
Functor (OMap k) Source # 
Instance details

Defined in Language.Haskell.TH.Desugar.OMap

Methods

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

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

Foldable (OMap k) Source # 
Instance details

Defined in Language.Haskell.TH.Desugar.OMap

Methods

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

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

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

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

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

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

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

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

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

null :: OMap k a -> Bool #

length :: OMap k a -> Int #

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

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

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

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

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

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) #

sequenceA :: Applicative f => OMap k (f a) -> f (OMap k a) #

mapM :: Monad m => (a -> m b) -> OMap k a -> m (OMap k b) #

sequence :: Monad m => OMap k (m a) -> m (OMap k a) #

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

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

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

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

toConstr :: OMap k v -> Constr #

dataTypeOf :: OMap k v -> DataType #

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

readList :: ReadS [OMap k v] #

readPrec :: ReadPrec (OMap k v) #

readListPrec :: ReadPrec [OMap k v] #

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

show :: OMap k v -> String #

showList :: [OMap k v] -> ShowS #

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 #

sconcat :: NonEmpty (OMap k v) -> OMap k v #

stimes :: Integral b => b -> OMap k v -> OMap k v #

Ord k => Monoid (OMap k v) Source # 
Instance details

Defined in Language.Haskell.TH.Desugar.OMap

Methods

mempty :: OMap k v #

mappend :: OMap k v -> OMap k v -> OMap k v #

mconcat :: [OMap k v] -> OMap k v #

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 #

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 #