tree-diff-0.3.0.1: Diffing of (expression) trees.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.TreeDiff.OMap

Description

Map which remembers the fromList order. This module is minimal on purpose.

Synopsis

Ordered map

data OMap k v Source #

Instances

Instances details
(Ord k, Arbitrary k) => Arbitrary1 (OMap k) Source # 
Instance details

Defined in Data.TreeDiff.OMap

Methods

liftArbitrary :: Gen a -> Gen (OMap k a) #

liftShrink :: (a -> [a]) -> OMap k a -> [OMap k a] #

Functor (OMap k) Source # 
Instance details

Defined in Data.TreeDiff.OMap

Methods

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

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

Ord k => Semialign (OMap k) Source #
>>> let xs = fromList [('a', "alpha"), ('b', "beta")]
>>> let ys = fromList [('c', 3 :: Int), ('b', 2)]
>>> alignWith id xs ys
fromList [('a',This "alpha"),('c',That 3),('b',These "beta" 2)]
Instance details

Defined in Data.TreeDiff.OMap

Methods

align :: OMap k a -> OMap k b -> OMap k (These a b) #

alignWith :: (These a b -> c) -> OMap k a -> OMap k b -> OMap k c #

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

Defined in Data.TreeDiff.OMap

Methods

arbitrary :: Gen (OMap k v) #

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

(Show k, Show v) => Show (OMap k v) Source #

Note: The instance uses toList, so Equal OMaps can be shown differently.

Instance details

Defined in Data.TreeDiff.OMap

Methods

showsPrec :: Int -> OMap k v -> ShowS #

show :: OMap k v -> String #

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

(NFData k, NFData v) => NFData (OMap k v) Source # 
Instance details

Defined in Data.TreeDiff.OMap

Methods

rnf :: OMap k v -> () #

(Eq k, Eq v) => Eq (OMap k v) Source #
>>> xs = toAscList $ fromList [('a', "alpha"), ('b', "beta"), ('g', "gamma")]
>>> ys = toAscList $ fromList [('g', "gamma"), ('b', "beta"), ('a', "alpha")]
>>> xs == ys
True
>>> zs = toAscList $ fromList [('d', "delta"), ('b', "beta"), ('a', "alpha")]
>>> xs == zs
False
Instance details

Defined in Data.TreeDiff.OMap

Methods

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

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

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

Defined in Data.TreeDiff.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 #

Conversions

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

>>> toAscList $ fromList [('a', "alpha"), ('b', "beta"), ('g', "gamma")]
[('a',"alpha"),('b',"beta"),('g',"gamma")]
>>> toAscList $ fromList [('g', "gamma"), ('b', "beta"), ('a', "alpha")]
[('a',"alpha"),('b',"beta"),('g',"gamma")]

toList :: OMap k v -> [(k, v)] Source #

O(n log n). List in creation order. Doesn't respect Eq instance.

>>> toList $ fromList [('a', "alpha"), ('b', "beta"), ('g', "gamma")]
[('a',"alpha"),('b',"beta"),('g',"gamma")]
>>> toList $ fromList [('g', "gamma"), ('b', "beta"), ('a', "alpha")]
[('g',"gamma"),('b',"beta"),('a',"alpha")]

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

>>> fromList [('g', "gamma"), ('b', "beta"), ('a', "alpha")]
fromList [('g',"gamma"),('b',"beta"),('a',"alpha")]

Construction

empty :: OMap k v Source #

>>> empty :: OMap String Integer
fromList []

Query

elems :: OMap k v -> [v] Source #

Elements in key ascending order.