brassica-0.0.3: Featureful sound change applier
Safe HaskellSafe-Inferred
LanguageHaskell2010

Brassica.SoundChange.Category

Synopsis

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 Categorys; these references can then be expanded, allowing the Category to be baked 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 Categorys are still quite convenient to construct manually.

Constructors

Empty

The empty category ([] in Brassica syntax)

Node a

A single value ([a])

UnionOf [Category s a]

The union of multiple categories ([Ca Cb Cc])

Intersect (Category s a) (Category s a)

The intersection of two categories ([Ca +Cb])

Subtract (Category s a) (Category s a)

The second category subtracted from the first ([Ca -Cb])

Instances

Instances details
Functor (Category s) Source # 
Instance details

Defined in Brassica.SoundChange.Category

Methods

fmap :: (a -> b) -> Category s a -> Category s b #

(<$) :: a -> Category s b -> Category s a #

Show a => Show (Category s a) Source # 
Instance details

Defined in Brassica.SoundChange.Category

Methods

showsPrec :: Int -> Category s a -> ShowS #

show :: Category s a -> String #

showList :: [Category s a] -> ShowS #

Eq a => Eq (Category s a) Source # 
Instance details

Defined in Brassica.SoundChange.Category

Methods

(==) :: Category s a -> Category s a -> Bool #

(/=) :: Category s a -> Category s a -> Bool #

Ord a => Ord (Category s a) Source # 
Instance details

Defined in Brassica.SoundChange.Category

Methods

compare :: Category s a -> Category s a -> Ordering #

(<) :: Category s a -> Category s a -> Bool #

(<=) :: Category s a -> Category s a -> Bool #

(>) :: Category s a -> Category s a -> Bool #

(>=) :: Category s a -> Category s a -> Bool #

max :: Category s a -> Category s a -> Category s a #

min :: Category s a -> Category s a -> Category s a #

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.

Constructors

Unexpanded 
Expanded 

categorise :: Ord a => [a] -> Category 'Expanded a Source #

Given a list of values, return a Category which matches only those values. (This is a simple wrapper around Node and UnionOf.)

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.lookup, specialised to 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 Intersected or Subtracted out: e.g. given Categories including [a b -a], this will return a list including ["a","b"], not just ["b"].