th-desugar-1.14: 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.OSet

Contents

- Trivial sets
- Insertion
- Query
- Deletion
- Indexing
- List conversions
- `Set` conversion

Description

An `OSet` behaves much like a `Set`, with all the same asymptotics, but also remembers the order that values were inserted.

This module offers a simplified version of the Data.Set.Ordered API that assumes left-biased indices everywhere.

Synopsis

- data OSet a
- empty :: forall a. OSet a
- singleton :: a -> OSet a
- insertPre :: Ord a => a -> OSet a -> OSet a
- insertPost :: Ord a => OSet a -> a -> OSet a
- union :: forall a. Ord a => OSet a -> OSet a -> OSet a
- null :: forall a. OSet a -> Bool
- size :: forall a. OSet a -> Int
- member :: Ord a => a -> OSet a -> Bool
- notMember :: Ord a => a -> OSet a -> Bool
- delete :: Ord a => a -> OSet a -> OSet a
- filter :: Ord a => (a -> Bool) -> OSet a -> OSet a
- (\\) :: forall a. Ord a => OSet a -> OSet a -> OSet a
- intersection :: forall a. Ord a => OSet a -> OSet a -> OSet a
- type Index = Int
- lookupIndex :: Ord a => a -> OSet a -> Maybe Index
- lookupAt :: forall a. Index -> OSet a -> Maybe a
- fromList :: Ord a => [a] -> OSet a
- toAscList :: forall a. OSet a -> [a]
- toSet :: forall a. OSet a -> Set a

# Documentation

data OSet a Source #

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

#### Instances

Instances details

Foldable OSet Source # |

Instance details

Defined in Language.Haskell.TH.Desugar.OSet

Methods

fold :: Monoid m => OSet m -> m Source #

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

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

foldr :: (a -> b -> b) -> b -> OSet a -> b Source #

foldr' :: (a -> b -> b) -> b -> OSet a -> b Source #

foldl :: (b -> a -> b) -> b -> OSet a -> b Source #

foldl' :: (b -> a -> b) -> b -> OSet a -> b Source #

foldr1 :: (a -> a -> a) -> OSet a -> a Source #

foldl1 :: (a -> a -> a) -> OSet a -> a Source #

toList :: OSet a -> [a] Source #

null :: OSet a -> Bool Source #

length :: OSet a -> Int Source #

elem :: Eq a => a -> OSet a -> Bool Source #

maximum :: Ord a => OSet a -> a Source #

minimum :: Ord a => OSet a -> a Source #

sum :: Num a => OSet a -> a Source #

product :: Num a => OSet a -> a Source #

(Data a, Ord a) => Data (OSet a) Source # |

Instance details

Defined in Language.Haskell.TH.Desugar.OSet

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> OSet a -> c (OSet a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (OSet a) Source #

toConstr :: OSet a -> Constr Source #

dataTypeOf :: OSet a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (OSet a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (OSet a)) Source #

gmapT :: (forall b. Data b => b -> b) -> OSet a -> OSet a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OSet a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OSet a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> OSet a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> OSet a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> OSet a -> m (OSet a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> OSet a -> m (OSet a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> OSet a -> m (OSet a) Source #

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

# Trivial sets

empty :: forall a. OSet a Source #

singleton :: a -> OSet a Source #

# Insertion

insertPre :: Ord a => a -> OSet a -> OSet a Source #

The element's index will be lower than the indices of the elements in the `OSet`.

insertPost :: Ord a => OSet a -> a -> OSet a Source #

The element's index will be higher than the indices of the elements in the `OSet`.

union :: forall a. Ord a => OSet a -> OSet a -> OSet a Source #

# Query

null :: forall a. OSet a -> Bool Source #

size :: forall a. OSet a -> Int Source #

member :: Ord a => a -> OSet a -> Bool Source #

notMember :: Ord a => a -> OSet a -> Bool Source #

# Deletion

delete :: Ord a => a -> OSet a -> OSet a Source #

filter :: Ord a => (a -> Bool) -> OSet a -> OSet a Source #

(\\) :: forall a. Ord a => OSet a -> OSet a -> OSet a Source #

intersection :: forall a. Ord a => OSet a -> OSet a -> OSet a 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 :: Ord a => a -> OSet a -> Maybe Index Source #

lookupAt :: forall a. Index -> OSet a -> Maybe a Source #

# List conversions

fromList :: Ord a => [a] -> OSet a Source #

toAscList :: forall a. OSet a -> [a] Source #

# `Set` conversion

toSet :: forall a. OSet a -> Set a Source #