Safe Haskell | None |
---|---|
Language | Haskell2010 |
Languages supported by different fonts.
Synopsis
- type LangSet = Set String
- newtype LangSet' = LangSet' {}
- data Set a
- fromList :: Ord a => [a] -> Set a
- toList :: Set a -> [a]
- delete :: Ord a => a -> Set a -> Set a
- foldr :: (a -> b -> b) -> b -> Set a -> b
- map :: Ord b => (a -> b) -> Set a -> Set b
- elems :: Set a -> [a]
- filter :: (a -> Bool) -> Set a -> Set a
- foldl :: (a -> b -> a) -> a -> Set b -> a
- empty :: Set a
- null :: Set a -> Bool
- foldl' :: (a -> b -> a) -> a -> Set b -> a
- foldr' :: (a -> b -> b) -> b -> Set a -> b
- take :: Int -> Set a -> Set a
- drop :: Int -> Set a -> Set a
- splitAt :: Int -> Set a -> (Set a, Set a)
- fold :: (a -> b -> b) -> b -> Set a -> b
- findIndex :: Ord a => a -> Set a -> Int
- (\\) :: Ord a => Set a -> Set a -> Set a
- union :: Ord a => Set a -> Set a -> Set a
- partition :: (a -> Bool) -> Set a -> (Set a, Set a)
- insert :: Ord a => a -> Set a -> Set a
- singleton :: a -> Set a
- size :: Set a -> Int
- findMin :: Set a -> a
- deleteMin :: Set a -> Set a
- minView :: Set a -> Maybe (a, Set a)
- split :: Ord a => a -> Set a -> (Set a, Set a)
- showTree :: Show a => Set a -> String
- showTreeWith :: Show a => Bool -> Bool -> Set a -> String
- member :: Ord a => a -> Set a -> Bool
- notMember :: Ord a => a -> Set a -> Bool
- lookupLT :: Ord a => a -> Set a -> Maybe a
- lookupGT :: Ord a => a -> Set a -> Maybe a
- lookupLE :: Ord a => a -> Set a -> Maybe a
- lookupGE :: Ord a => a -> Set a -> Maybe a
- alterF :: (Ord a, Functor f) => (Bool -> f Bool) -> a -> Set a -> f (Set a)
- isProperSubsetOf :: Ord a => Set a -> Set a -> Bool
- isSubsetOf :: Ord a => Set a -> Set a -> Bool
- disjoint :: Ord a => Set a -> Set a -> Bool
- lookupMin :: Set a -> Maybe a
- lookupMax :: Set a -> Maybe a
- findMax :: Set a -> a
- deleteMax :: Set a -> Set a
- unions :: (Foldable f, Ord a) => f (Set a) -> Set a
- difference :: Ord a => Set a -> Set a -> Set a
- intersection :: Ord a => Set a -> Set a -> Set a
- mapMonotonic :: (a -> b) -> Set a -> Set b
- toAscList :: Set a -> [a]
- toDescList :: Set a -> [a]
- fromAscList :: Eq a => [a] -> Set a
- fromDescList :: Eq a => [a] -> Set a
- fromDistinctAscList :: [a] -> Set a
- fromDistinctDescList :: [a] -> Set a
- splitMember :: Ord a => a -> Set a -> (Set a, Bool, Set a)
- lookupIndex :: Ord a => a -> Set a -> Maybe Int
- elemAt :: Int -> Set a -> a
- deleteAt :: Int -> Set a -> Set a
- takeWhileAntitone :: (a -> Bool) -> Set a -> Set a
- dropWhileAntitone :: (a -> Bool) -> Set a -> Set a
- spanAntitone :: (a -> Bool) -> Set a -> (Set a, Set a)
- deleteFindMin :: Set a -> (a, Set a)
- deleteFindMax :: Set a -> (a, Set a)
- maxView :: Set a -> Maybe (a, Set a)
- splitRoot :: Set a -> [Set a]
- powerSet :: Set a -> Set (Set a)
- cartesianProduct :: Set a -> Set b -> Set (a, b)
- disjointUnion :: Set a -> Set b -> Set (Either a b)
- data LangComparison
- validLangSet :: LangSet -> Bool
- validLangSet' :: LangSet' -> Bool
- cmp :: LangSet -> LangSet -> LangComparison
- cmp' :: LangSet' -> LangSet' -> LangComparison
- has :: LangSet' -> String -> LangComparison
- defaultLangs :: StrSet
- langs :: StrSet
- normalize :: String -> String
- langCharSet :: String -> CharSet'
Documentation
type LangSet = Set String Source #
A set of language names (each of which include language and an optional territory). They are used when selecting fonts to indicate which languages the fonts need to support. Each font is marked, using language orthography information built into fontconfig, with the set of supported languages.
Wrapper around LangSet adding useful typeclasses
A set of values a
.
Instances
Foldable Set | Folds in order of increasing key. |
Defined in Data.Set.Internal fold :: Monoid m => Set m -> m # foldMap :: Monoid m => (a -> m) -> Set a -> m # foldMap' :: Monoid m => (a -> m) -> Set a -> m # foldr :: (a -> b -> b) -> b -> Set a -> b # foldr' :: (a -> b -> b) -> b -> Set a -> b # foldl :: (b -> a -> b) -> b -> Set a -> b # foldl' :: (b -> a -> b) -> b -> Set a -> b # foldr1 :: (a -> a -> a) -> Set a -> a # foldl1 :: (a -> a -> a) -> Set a -> a # elem :: Eq a => a -> Set a -> Bool # maximum :: Ord a => Set a -> a # | |
Eq1 Set | Since: containers-0.5.9 |
Ord1 Set | Since: containers-0.5.9 |
Defined in Data.Set.Internal | |
Show1 Set | Since: containers-0.5.9 |
Hashable1 Set | Since: hashable-1.3.4.0 |
Defined in Data.Hashable.Class | |
Lift a => Lift (Set a :: Type) | Since: containers-0.6.6 |
(Ord a, Arbitrary a) => Arbitrary (Set a) | WARNING: Users working on the internals of the |
CoArbitrary a => CoArbitrary (Set a) | |
Defined in Test.QuickCheck.Arbitrary coarbitrary :: Set a -> Gen b -> Gen b # | |
(Data a, Ord a) => Data (Set a) | |
Defined in Data.Set.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Set a -> c (Set a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Set a) # dataTypeOf :: Set a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Set a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Set a)) # gmapT :: (forall b. Data b => b -> b) -> Set a -> Set a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Set a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Set a -> r # gmapQ :: (forall d. Data d => d -> u) -> Set a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Set a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Set a -> m (Set a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Set a -> m (Set a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Set a -> m (Set a) # | |
Ord a => Monoid (Set a) | |
Ord a => Semigroup (Set a) | Since: containers-0.5.7 |
Ord a => IsList (Set a) | Since: containers-0.5.6.2 |
(Read a, Ord a) => Read (Set a) | |
Show a => Show (Set a) | |
NFData a => NFData (Set a) | |
Defined in Data.Set.Internal | |
Eq a => Eq (Set a) | |
Ord a => Ord (Set a) | |
Hashable v => Hashable (Set v) | Since: hashable-1.3.4.0 |
Defined in Data.Hashable.Class | |
Ord k => At (Set k) | |
Ord a => Contains (Set a) | |
Ord k => Ixed (Set k) | |
Defined in Control.Lens.At | |
Ord a => Wrapped (Set a) | |
(t ~ Set a', Ord a) => Rewrapped (Set a) t | |
Defined in Control.Lens.Wrapped | |
type Item (Set a) | |
Defined in Data.Set.Internal | |
type Index (Set a) | |
Defined in Control.Lens.At | |
type IxValue (Set k) | |
Defined in Control.Lens.At | |
type Unwrapped (Set a) | |
Defined in Control.Lens.Wrapped |
fromList :: Ord a => [a] -> Set a #
\(O(n \log n)\). Create a set from a list of elements.
If the elements are ordered, a linear-time implementation is used,
with the performance equal to fromDistinctAscList
.
map :: Ord b => (a -> b) -> Set a -> Set b #
\(O(n \log n)\).
is the set obtained by applying map
f sf
to each element of s
.
It's worth noting that the size of the result may be smaller if,
for some (x,y)
, x /= y && f x == f y
\(O(n)\). An alias of toAscList
. The elements of a set in ascending order.
Subject to list fusion.
foldl' :: (a -> b -> a) -> a -> Set b -> a #
\(O(n)\). A strict version of foldl
. Each application of the operator is
evaluated before using the result in the next application. This
function is strict in the starting value.
foldr' :: (a -> b -> b) -> b -> Set a -> b #
\(O(n)\). A strict version of foldr
. Each application of the operator is
evaluated before using the result in the next application. This
function is strict in the starting value.
take :: Int -> Set a -> Set a #
\(O(\log n)\). Take a given number of elements in order, beginning with the smallest ones.
take n =fromDistinctAscList
.take
n .toAscList
Since: containers-0.5.8
drop :: Int -> Set a -> Set a #
\(O(\log n)\). Drop a given number of elements in order, beginning with the smallest ones.
drop n =fromDistinctAscList
.drop
n .toAscList
Since: containers-0.5.8
fold :: (a -> b -> b) -> b -> Set a -> b #
\(O(n)\). Fold the elements in the set using the given right-associative
binary operator. This function is an equivalent of foldr
and is present
for compatibility only.
Please note that fold will be deprecated in the future and removed.
findIndex :: Ord a => a -> Set a -> Int #
\(O(\log n)\). Return the index of an element, which is its zero-based
index in the sorted sequence of elements. The index is a number from 0 up
to, but not including, the size
of the set. Calls error
when the element
is not a member
of the set.
findIndex 2 (fromList [5,3]) Error: element is not in the set findIndex 3 (fromList [5,3]) == 0 findIndex 5 (fromList [5,3]) == 1 findIndex 6 (fromList [5,3]) Error: element is not in the set
Since: containers-0.5.4
(\\) :: Ord a => Set a -> Set a -> Set a infixl 9 #
\(O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n\). See difference
.
union :: Ord a => Set a -> Set a -> Set a #
\(O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n\). The union of two sets, preferring the first set when equal elements are encountered.
partition :: (a -> Bool) -> Set a -> (Set a, Set a) #
\(O(n)\). Partition the set into two sets, one with all elements that satisfy
the predicate and one with all elements that don't satisfy the predicate.
See also split
.
insert :: Ord a => a -> Set a -> Set a #
\(O(\log n)\). Insert an element in a set. If the set already contains an element equal to the given value, it is replaced with the new value.
\(O(\log n)\). Delete the minimal element. Returns an empty set if the set is empty.
minView :: Set a -> Maybe (a, Set a) #
\(O(\log n)\). Retrieves the minimal key of the set, and the set
stripped of that element, or Nothing
if passed an empty set.
split :: Ord a => a -> Set a -> (Set a, Set a) #
\(O(\log n)\). The expression (
) is a pair split
x set(set1,set2)
where set1
comprises the elements of set
less than x
and set2
comprises the elements of set
greater than x
.
showTree :: Show a => Set a -> String #
\(O(n \log n)\). Show the tree that implements the set. The tree is shown in a compressed, hanging format.
showTreeWith :: Show a => Bool -> Bool -> Set a -> String #
\(O(n \log n)\). The expression (showTreeWith hang wide map
) shows
the tree that implements the set. If hang
is
True
, a hanging tree is shown otherwise a rotated tree is shown. If
wide
is True
, an extra wide version is shown.
Set> putStrLn $ showTreeWith True False $ fromDistinctAscList [1..5] 4 +--2 | +--1 | +--3 +--5 Set> putStrLn $ showTreeWith True True $ fromDistinctAscList [1..5] 4 | +--2 | | | +--1 | | | +--3 | +--5 Set> putStrLn $ showTreeWith False True $ fromDistinctAscList [1..5] +--5 | 4 | | +--3 | | +--2 | +--1
lookupLT :: Ord a => a -> Set a -> Maybe a #
\(O(\log n)\). Find largest element smaller than the given one.
lookupLT 3 (fromList [3, 5]) == Nothing lookupLT 5 (fromList [3, 5]) == Just 3
lookupGT :: Ord a => a -> Set a -> Maybe a #
\(O(\log n)\). Find smallest element greater than the given one.
lookupGT 4 (fromList [3, 5]) == Just 5 lookupGT 5 (fromList [3, 5]) == Nothing
lookupLE :: Ord a => a -> Set a -> Maybe a #
\(O(\log n)\). Find largest element smaller or equal to the given one.
lookupLE 2 (fromList [3, 5]) == Nothing lookupLE 4 (fromList [3, 5]) == Just 3 lookupLE 5 (fromList [3, 5]) == Just 5
lookupGE :: Ord a => a -> Set a -> Maybe a #
\(O(\log n)\). Find smallest element greater or equal to the given one.
lookupGE 3 (fromList [3, 5]) == Just 3 lookupGE 4 (fromList [3, 5]) == Just 5 lookupGE 6 (fromList [3, 5]) == Nothing
alterF :: (Ord a, Functor f) => (Bool -> f Bool) -> a -> Set a -> f (Set a) #
\(O(\log n)\) (
can delete or insert alterF
f x s)x
in s
depending on
whether an equal element is found in s
.
In short:
member
x <$>alterF
f x s = f (member
x s)
Note that unlike insert
, alterF
will not replace an element equal to
the given value.
Note: alterF
is a variant of the at
combinator from Control.Lens.At.
Since: containers-0.6.3.1
isProperSubsetOf :: Ord a => Set a -> Set a -> Bool #
\(O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n\).
(s1 `isProperSubsetOf` s2)
indicates whether s1
is a
proper subset of s2
.
s1 `isProperSubsetOf` s2 = s1 `isSubsetOf`
s2 && s1 /= s2
isSubsetOf :: Ord a => Set a -> Set a -> Bool #
\(O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n\).
(s1 `isSubsetOf` s2)
indicates whether s1
is a subset of s2
.
s1 `isSubsetOf` s2 = all (`member`
s2) s1 s1 `isSubsetOf` s2 = null (s1`difference`
s2) s1 `isSubsetOf` s2 = s1`union`
s2 == s2 s1 `isSubsetOf` s2 = s1`intersection`
s2 == s1
disjoint :: Ord a => Set a -> Set a -> Bool #
\(O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n\). Check whether two sets are disjoint (i.e., their intersection is empty).
disjoint (fromList [2,4,6]) (fromList [1,3]) == True disjoint (fromList [2,4,6,8]) (fromList [2,3,5,7]) == False disjoint (fromList [1,2]) (fromList [1,2,3,4]) == False disjoint (fromList []) (fromList []) == True
xs`disjoint`
ys = null (xs`intersection`
ys)
Since: containers-0.5.11
\(O(\log n)\). Delete the maximal element. Returns an empty set if the set is empty.
difference :: Ord a => Set a -> Set a -> Set a #
\(O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n\). Difference of two sets.
Return elements of the first set not existing in the second set.
difference (fromList [5, 3]) (fromList [5, 7]) == singleton 3
intersection :: Ord a => Set a -> Set a -> Set a #
\(O\bigl(m \log\bigl(\frac{n+1}{m+1}\bigr)\bigr), \; m \leq n\). The intersection of two sets. Elements of the result come from the first set, so for example
import qualified Data.Set as S data AB = A | B deriving Show instance Ord AB where compare _ _ = EQ instance Eq AB where _ == _ = True main = print (S.singleton A `S.intersection` S.singleton B, S.singleton B `S.intersection` S.singleton A)
prints (fromList [A],fromList [B])
.
mapMonotonic :: (a -> b) -> Set a -> Set b #
\(O(n)\). The
, but works only when mapMonotonic
f s == map
f sf
is strictly increasing.
The precondition is not checked.
Semi-formally, we have:
and [x < y ==> f x < f y | x <- ls, y <- ls] ==> mapMonotonic f s == map f s where ls = toList s
\(O(n)\). Convert the set to an ascending list of elements. Subject to list fusion.
toDescList :: Set a -> [a] #
\(O(n)\). Convert the set to a descending list of elements. Subject to list fusion.
fromAscList :: Eq a => [a] -> Set a #
\(O(n)\). Build a set from an ascending list in linear time. The precondition (input list is ascending) is not checked.
fromDescList :: Eq a => [a] -> Set a #
\(O(n)\). Build a set from a descending list in linear time. The precondition (input list is descending) is not checked.
Since: containers-0.5.8
fromDistinctAscList :: [a] -> Set a #
\(O(n)\). Build a set from an ascending list of distinct elements in linear time. The precondition (input list is strictly ascending) is not checked.
fromDistinctDescList :: [a] -> Set a #
\(O(n)\). Build a set from a descending list of distinct elements in linear time. The precondition (input list is strictly descending) is not checked.
splitMember :: Ord a => a -> Set a -> (Set a, Bool, Set a) #
\(O(\log n)\). Performs a split
but also returns whether the pivot
element was found in the original set.
lookupIndex :: Ord a => a -> Set a -> Maybe Int #
\(O(\log n)\). Lookup the index of an element, which is its zero-based index in
the sorted sequence of elements. The index is a number from 0 up to, but not
including, the size
of the set.
isJust (lookupIndex 2 (fromList [5,3])) == False fromJust (lookupIndex 3 (fromList [5,3])) == 0 fromJust (lookupIndex 5 (fromList [5,3])) == 1 isJust (lookupIndex 6 (fromList [5,3])) == False
Since: containers-0.5.4
\(O(\log n)\). Retrieve an element by its index, i.e. by its zero-based
index in the sorted sequence of elements. If the index is out of range (less
than zero, greater or equal to size
of the set), error
is called.
elemAt 0 (fromList [5,3]) == 3 elemAt 1 (fromList [5,3]) == 5 elemAt 2 (fromList [5,3]) Error: index out of range
Since: containers-0.5.4
deleteAt :: Int -> Set a -> Set a #
\(O(\log n)\). Delete the element at index, i.e. by its zero-based index in
the sorted sequence of elements. If the index is out of range (less than zero,
greater or equal to size
of the set), error
is called.
deleteAt 0 (fromList [5,3]) == singleton 5 deleteAt 1 (fromList [5,3]) == singleton 3 deleteAt 2 (fromList [5,3]) Error: index out of range deleteAt (-1) (fromList [5,3]) Error: index out of range
Since: containers-0.5.4
takeWhileAntitone :: (a -> Bool) -> Set a -> Set a #
\(O(\log n)\). Take while a predicate on the elements holds.
The user is responsible for ensuring that for all elements j
and k
in the set,
j < k ==> p j >= p k
. See note at spanAntitone
.
takeWhileAntitone p =fromDistinctAscList
.takeWhile
p .toList
takeWhileAntitone p =filter
p
Since: containers-0.5.8
dropWhileAntitone :: (a -> Bool) -> Set a -> Set a #
\(O(\log n)\). Drop while a predicate on the elements holds.
The user is responsible for ensuring that for all elements j
and k
in the set,
j < k ==> p j >= p k
. See note at spanAntitone
.
dropWhileAntitone p =fromDistinctAscList
.dropWhile
p .toList
dropWhileAntitone p =filter
(not . p)
Since: containers-0.5.8
spanAntitone :: (a -> Bool) -> Set a -> (Set a, Set a) #
\(O(\log n)\). Divide a set at the point where a predicate on the elements stops holding.
The user is responsible for ensuring that for all elements j
and k
in the set,
j < k ==> p j >= p k
.
spanAntitone p xs = (takeWhileAntitone
p xs,dropWhileAntitone
p xs) spanAntitone p xs = partition p xs
Note: if p
is not actually antitone, then spanAntitone
will split the set
at some unspecified point where the predicate switches from holding to not
holding (where the predicate is seen to hold before the first element and to fail
after the last element).
Since: containers-0.5.8
deleteFindMin :: Set a -> (a, Set a) #
\(O(\log n)\). Delete and find the minimal element.
deleteFindMin set = (findMin set, deleteMin set)
deleteFindMax :: Set a -> (a, Set a) #
\(O(\log n)\). Delete and find the maximal element.
deleteFindMax set = (findMax set, deleteMax set)
maxView :: Set a -> Maybe (a, Set a) #
\(O(\log n)\). Retrieves the maximal key of the set, and the set
stripped of that element, or Nothing
if passed an empty set.
splitRoot :: Set a -> [Set a] #
\(O(1)\). Decompose a set into pieces based on the structure of the underlying tree. This function is useful for consuming a set in parallel.
No guarantee is made as to the sizes of the pieces; an internal, but deterministic process determines this. However, it is guaranteed that the pieces returned will be in ascending order (all elements in the first subset less than all elements in the second, and so on).
Examples:
splitRoot (fromList [1..6]) == [fromList [1,2,3],fromList [4],fromList [5,6]]
splitRoot empty == []
Note that the current implementation does not return more than three subsets, but you should not depend on this behaviour because it can change in the future without notice.
Since: containers-0.5.4
powerSet :: Set a -> Set (Set a) #
\(O(2^n \log n)\). Calculate the power set of a set: the set of all its subsets.
t`member`
powerSet s == t`isSubsetOf`
s
Example:
powerSet (fromList [1,2,3]) = fromList $ map fromList [[],[1],[1,2],[1,2,3],[1,3],[2],[2,3],[3]]
Since: containers-0.5.11
cartesianProduct :: Set a -> Set b -> Set (a, b) #
\(O(nm)\). Calculate the Cartesian product of two sets.
cartesianProduct xs ys = fromList $ liftA2 (,) (toList xs) (toList ys)
Example:
cartesianProduct (fromList [1,2]) (fromList ['a','b']) = fromList [(1,'a'), (1,'b'), (2,'a'), (2,'b')]
Since: containers-0.5.11
disjointUnion :: Set a -> Set b -> Set (Either a b) #
\(O(n+m)\). Calculate the disjoint union of two sets.
disjointUnion xs ys = map Left xs `union`
map Right ys
Example:
disjointUnion (fromList [1,2]) (fromList ["hi", "bye"]) = fromList [Left 1, Left 2, Right "hi", Right "bye"]
Since: containers-0.5.11
data LangComparison Source #
The result of cmp
.
DifferentLang | The locales share no languages in common |
SameLang | The locales share any language and territory pair |
DifferentTerritory | The locales share a language but differ in which territory that language is for |
Instances
validLangSet :: LangSet -> Bool Source #
Can the given LangSet be processed by FontConfig?
validLangSet' :: LangSet' -> Bool Source #
Can the given LangSet' be processed by FontConfig?
cmp' :: LangSet' -> LangSet' -> LangComparison Source #
Compares language coverage for the 2 given LangSets.
has :: LangSet' -> String -> LangComparison Source #
returns True if a
contains every language in b
.
a
` will contain a language from b
if a
has exactly the language,
or either the language or a
has no territory.
defaultLangs :: StrSet Source #
Returns a string set of the default languages according to the environment variables on the system. This function looks for them in order of FC_LANG, LC_ALL, LC_CTYPE and LANG then. If there are no valid values in those environment variables, "en" will be set as fallback.
langCharSet :: String -> CharSet' Source #
Returns the CharSet for a language.