Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Category (s :: CategoryState) a
- data CategoryState
- categorise :: Ord a => [a] -> Category 'Expanded a
- type Categories a = Map a (Category 'Expanded a)
- lookup :: Ord a => a -> Categories a -> Maybe (Category 'Expanded a)
- mapCategories :: Ord b => (a -> b) -> Categories a -> Categories b
- expand :: Ord a => Categories a -> Category 'Unexpanded a -> Category 'Expanded a
- bake :: Eq a => Category 'Expanded a -> [a]
- values :: Ord a => Categories a -> [a]
Category construction
data Category (s :: CategoryState) a Source #
A set of values (usually representing phonemes) which behave the
same way in a sound change. A Category
is constructed using the
set operations supplied as constructors, possibly referencing other
Category
s; these references can then be expand
ed, allowing the
Category
to be bake
d to a list of matching values.
Note that Brassica makes no distinction between ad-hoc categories
and predefined categories beyond the sound change parser; the
latter is merely syntax sugar for the former, and both are
represented using the same Category
type. In practise this is not
usually a problem, since Category
s are still quite convenient to
construct manually.
Empty | The empty category ( |
Node a | A single value ( |
UnionOf [Category s a] | The union of multiple categories ( |
Intersect (Category s a) (Category s a) | The intersection of two categories ( |
Subtract (Category s a) (Category s a) | The second category subtracted from the first ( |
Instances
Functor (Category s) Source # | |
Show a => Show (Category s a) Source # | |
Eq a => Eq (Category s a) Source # | |
Ord a => Ord (Category s a) Source # | |
Defined in Brassica.SoundChange.Category |
data CategoryState Source #
Type-level tag for Category
. When parsing a category definition
from a string, usually categories will refer to other
categories. This is the Unexpanded
state. Once Expanded
, these
references will have been inlined, and the category no longer
depends on other categories.
Category expansion
type Categories a = Map a (Category 'Expanded a) Source #
A map from names to the (expanded) categories they reference. Used to resolve cross-references between categories.
lookup :: Ord a => a -> Categories a -> Maybe (Category 'Expanded a) Source #
Data.Map.Strict.
, specialised to lookup
Categories
.
mapCategories :: Ord b => (a -> b) -> Categories a -> Categories b Source #
Map a function over all the values in a set of Categories
.
expand :: Ord a => Categories a -> Category 'Unexpanded a -> Category 'Expanded a Source #
Expand an Unexpanded
category by inlining its references. The
references should only be to categories in the given Categories
.
Obtaining values
bake :: Eq a => Category 'Expanded a -> [a] Source #
Given an Expanded
category, return the list of values which it
matches.
values :: Ord a => Categories a -> [a] Source #
Returns a list of every value mentioned in a set of
Categories
. This includes all values, even those which are
Intersect
ed or Subtract
ed out: e.g. given Categories
including [a b -a]
, this will return a list including
["a","b"]
, not just ["b"]
.