| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Brassica.SoundChange.Types
Synopsis
- data Grapheme
- type PWord = [Grapheme]
- addBoundaries :: PWord -> PWord
- removeBoundaries :: PWord -> PWord
- concatWithBoundary :: PWord -> String
- data Lexeme category (a :: LexemeType) where
- Grapheme :: Grapheme -> Lexeme category a
- Category :: category a -> Lexeme category a
- Optional :: [Lexeme category a] -> Lexeme category a
- Metathesis :: Lexeme category 'Replacement
- Geminate :: Lexeme category a
- Wildcard :: OneOf a 'Target 'Env => Lexeme category a -> Lexeme category a
- Kleene :: OneOf a 'Target 'Env => Lexeme category a -> Lexeme category a
- Discard :: Lexeme category 'Replacement
- Backreference :: Int -> category a -> Lexeme category a
- Multiple :: category 'Replacement -> Lexeme category 'Replacement
- pattern Boundary :: Lexeme c a
- data LexemeType
- = Target
- | Replacement
- | Env
- | AnyPart
- generalise :: (c 'AnyPart -> c a) -> Lexeme c 'AnyPart -> Lexeme c a
- mapCategory :: (forall x. c x -> c' x) -> Lexeme c a -> Lexeme c' a
- mapCategoryA :: Applicative t => (forall x. c x -> t (c' x)) -> Lexeme c a -> t (Lexeme c' a)
- newtype Expanded a = FromElements {}
- generaliseExpanded :: Expanded 'AnyPart -> Expanded a
- data Rule c = Rule {
- target :: [Lexeme c 'Target]
- replacement :: [Lexeme c 'Replacement]
- environment :: [Environment c]
- exception :: Maybe (Environment c)
- flags :: Flags
- plaintext :: String
- type Environment c = ([Lexeme c 'Env], [Lexeme c 'Env])
- data Direction
- data Flags = Flags {}
- defFlags :: Flags
- data Statement c decl
- = RuleS (Rule c)
- | DirectiveS decl
- plaintext' :: Statement c decl -> String
- type SoundChanges c decl = [Statement c decl]
- data CategoryModification
- data CategorySpec a
- data FeatureSpec = FeatureSpec {}
- data CategoryDefinition
- data Directive = Categories Bool [CategoryDefinition]
- type family OneOf a x y :: Constraint where ...
Words and graphemes
The type of graphemes within a word.
Constructors
| GMulti [Char] | A multigraph: for instance |
| GBoundary | A non-letter element representing a word boundary which sound changes can manipulate |
Instances
| IsString Grapheme Source # | |
Defined in Brassica.SoundChange.Types Methods fromString :: String -> Grapheme # | |
| Generic Grapheme Source # | |
| Show Grapheme Source # | |
| NFData Grapheme Source # | |
Defined in Brassica.SoundChange.Types | |
| Eq Grapheme Source # | |
| Ord Grapheme Source # | |
Defined in Brassica.SoundChange.Types | |
| type Rep Grapheme Source # | |
Defined in Brassica.SoundChange.Types type Rep Grapheme = D1 ('MetaData "Grapheme" "Brassica.SoundChange.Types" "brassica-0.2.0-6DYGqWgsRcQ5pGt1m6P3TU" 'False) (C1 ('MetaCons "GMulti" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Char])) :+: C1 ('MetaCons "GBoundary" 'PrefixI 'False) (U1 :: Type -> Type)) | |
addBoundaries :: PWord -> PWord Source #
removeBoundaries :: PWord -> PWord Source #
concatWithBoundary :: PWord -> String Source #
Lexemes
data Lexeme category (a :: LexemeType) where Source #
A Lexeme is the smallest part of a sound change. Both matches
and replacements are made up of Lexemes: the phantom type
variable a specifies where each different variety of Lexeme may
occur. Lexemes are also parameterised by their category type,
which may be Expanded or something else.
Constructors
| Grapheme :: Grapheme -> Lexeme category a | In Brassica sound-change syntax, one or more letters without intervening whitespace,
or a word boundary specified as |
| Category :: category a -> Lexeme category a | In Brassica sound-change syntax, delimited by square brackets |
| Optional :: [Lexeme category a] -> Lexeme category a | In Brassica sound-change syntax, delimited by parentheses |
| Metathesis :: Lexeme category 'Replacement | In Brassica sound-change syntax, specified as @@ |
| Geminate :: Lexeme category a | In Brassica sound-change syntax, specified as |
| Wildcard :: OneOf a 'Target 'Env => Lexeme category a -> Lexeme category a | In Brassica sound-change syntax, specified as |
| Kleene :: OneOf a 'Target 'Env => Lexeme category a -> Lexeme category a | In Brassica sound-change syntax, specified as |
| Discard :: Lexeme category 'Replacement | In Brassica sound-change syntax, specified as |
| Backreference :: Int -> category a -> Lexeme category a | In Brassica sound-change syntax, specified as @i before a category |
| Multiple :: category 'Replacement -> Lexeme category 'Replacement | In Brassica sound-change syntax, specified as @? before a category |
Instances
| (forall (x :: LexemeType). Show (c x)) => Show (Lexeme c a) Source # | |
| (forall (x :: LexemeType). NFData (c x)) => NFData (Lexeme c a) Source # | |
Defined in Brassica.SoundChange.Types | |
| (forall (x :: LexemeType). Eq (c x)) => Eq (Lexeme c a) Source # | |
| (forall (x :: LexemeType). Ord (c x)) => Ord (Lexeme c a) Source # | |
Defined in Brassica.SoundChange.Types | |
pattern Boundary :: Lexeme c a Source #
A Lexeme matching a single word boundary, specified as # in Brassica syntax.
data LexemeType Source #
The part of a Rule in which a Lexeme may occur: either the
target, the replacement or the environment, or in any of those.
Constructors
| Target | |
| Replacement | |
| Env | |
| AnyPart |
Categories
mapCategory :: (forall x. c x -> c' x) -> Lexeme c a -> Lexeme c' a Source #
mapCategoryA :: Applicative t => (forall x. c x -> t (c' x)) -> Lexeme c a -> t (Lexeme c' a) Source #
The type of a category after expansion.
Instances
| Monoid (Expanded a) Source # | |
| Semigroup (Expanded a) Source # | |
| Generic (Expanded a) Source # | |
| Show (Expanded a) Source # | |
| NFData (Expanded a) Source # | |
Defined in Brassica.SoundChange.Types | |
| Eq (Expanded a) Source # | |
| Ord (Expanded a) Source # | |
Defined in Brassica.SoundChange.Types | |
| type Rep (Expanded a) Source # | |
Defined in Brassica.SoundChange.Types type Rep (Expanded a) = D1 ('MetaData "Expanded" "Brassica.SoundChange.Types" "brassica-0.2.0-6DYGqWgsRcQ5pGt1m6P3TU" 'True) (C1 ('MetaCons "FromElements" 'PrefixI 'True) (S1 ('MetaSel ('Just "elements") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Either Grapheme [Lexeme Expanded a]]))) | |
Rules
A single sound change rule: in Brassica sound-change syntax with all elements specified,
-flags target / replacement / environment1 | environment2 | … / exception.
(And usually the plaintext of the rule will contain a String resembling that pattern.)
Constructors
| Rule | |
Fields
| |
Instances
type Environment c = ([Lexeme c 'Env], [Lexeme c 'Env]) Source #
An Environment is a tuple of (before, after) components,
corresponding to a ‘/ before _ after’ component of a sound change.
Note that an empty environment is just ([], []).
Specifies application direction of rule — either left-to-right or right-to-left.
Flags which can be enabled, disabled or altered on a Rule to
change how it is applied.
Constructors
| Flags | |
Fields
| |
Instances
| Generic Flags Source # | |
| Show Flags Source # | |
| NFData Flags Source # | |
Defined in Brassica.SoundChange.Types | |
| type Rep Flags Source # | |
Defined in Brassica.SoundChange.Types type Rep Flags = D1 ('MetaData "Flags" "Brassica.SoundChange.Types" "brassica-0.2.0-6DYGqWgsRcQ5pGt1m6P3TU" 'False) (C1 ('MetaCons "Flags" 'PrefixI 'True) ((S1 ('MetaSel ('Just "highlightChanges") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "applyDirection") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Direction)) :*: (S1 ('MetaSel ('Just "applyOnceOnly") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "sporadic") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))) | |
A default selection of flags which are appropriate for most rules:
defFlags=Flags{highlightChanges=True,applyDirection=LTR,applyOnceOnly=False,sporadic=False}
That is: highlight changes, apply from left to right, apply repeatedly, and don’t apply sporadically.
Statements
data Statement c decl Source #
A Statement can be either a single sound change rule, or a
directive (e.g. category definition).
Constructors
| RuleS (Rule c) | |
| DirectiveS decl |
Instances
| Generic (Statement c decl) Source # | |
| (forall (a :: LexemeType). Show (c a), Show decl) => Show (Statement c decl) Source # | |
| (forall (a :: LexemeType). NFData (c a), NFData decl) => NFData (Statement c decl) Source # | |
Defined in Brassica.SoundChange.Types | |
| type Rep (Statement c decl) Source # | |
Defined in Brassica.SoundChange.Types type Rep (Statement c decl) = D1 ('MetaData "Statement" "Brassica.SoundChange.Types" "brassica-0.2.0-6DYGqWgsRcQ5pGt1m6P3TU" 'False) (C1 ('MetaCons "RuleS" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Rule c))) :+: C1 ('MetaCons "DirectiveS" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 decl))) | |
plaintext' :: Statement c decl -> String Source #
A simple wrapper around plaintext for Statements. Returns
"directive" for all DirectiveS inputs.
type SoundChanges c decl = [Statement c decl] Source #
A set of SoundChanges is simply a list of Statements.
Directives
data CategoryModification Source #
The individual operations used to construct a category in Brassica sound-change syntax.
Instances
data CategorySpec a Source #
The specification of a category in Brassica sound-change syntax.
Constructors
| CategorySpec [(CategoryModification, Either Grapheme [Lexeme CategorySpec a])] | |
| MustInline String | A single grapheme assumed to have been specified earlier as a category |
Instances
data FeatureSpec Source #
The specification of a suprasegmental feature in Brassica sound-change syntax.
Constructors
| FeatureSpec | |
Fields | |
Instances
data CategoryDefinition Source #
A definition of a new category, either directly or via features.
Constructors
| DefineCategory String (CategorySpec 'AnyPart) | |
| DefineFeature FeatureSpec |
Instances
A directive used in Brassica sound-change syntax: currently only
categories … end or new categories … end
Constructors
| Categories Bool [CategoryDefinition] |
Instances
| Generic Directive Source # | |
| Show Directive Source # | |
| NFData Directive Source # | |
Defined in Brassica.SoundChange.Types | |
| Eq Directive Source # | |
| Ord Directive Source # | |
| type Rep Directive Source # | |
Defined in Brassica.SoundChange.Types type Rep Directive = D1 ('MetaData "Directive" "Brassica.SoundChange.Types" "brassica-0.2.0-6DYGqWgsRcQ5pGt1m6P3TU" 'False) (C1 ('MetaCons "Categories" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [CategoryDefinition]))) | |
Utility
type family OneOf a x y :: Constraint where ... Source #
The constraint OneOf a x y is satisfied if a ~ x or a ~ y.
(Note: the strange () ~ Bool constraint is just a simple
unsatisfiable constraint, so as to not give ‘non-exhaustive pattern
match’ errors everywhere.)