sound-change-0.1.0.0: Apply sound changes to words
Copyright(c) Owen Bechtel 2023
LicenseMIT
Maintainerombspring@gmail.com
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.Change

Description

 
Synopsis

Phoneme sets

data PSet a Source #

A finite set, or the complement of a finite set.

Constructors

PSet (Set a) Bool 

Instances

Instances details
Show a => Show (PSet a) Source # 
Instance details

Defined in Language.Change

Methods

showsPrec :: Int -> PSet a -> ShowS #

show :: PSet a -> String #

showList :: [PSet a] -> ShowS #

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

Test for membership in a PSet.

member x (PSet set b) = member x set == b

Environments

data Pattern a Source #

A single component of an Env.

Constructors

One (PSet a)

Matches one occurrence of a PSet member.

Optional (PSet a)

Matches zero or one occurences of a PSet member.

Many (PSet a)

Matches zero or more occurences of a PSet member.

Instances

Instances details
Show a => Show (Pattern a) Source # 
Instance details

Defined in Language.Change

Methods

showsPrec :: Int -> Pattern a -> ShowS #

show :: Pattern a -> String #

showList :: [Pattern a] -> ShowS #

data Env a Source #

An environment in which a phoneme (or in general, a value of type a), might occur. An Env is specified by two lists of patterns: the environment before the phoneme (ordered from nearest to farthest), and the environment after.

Constructors

Env [Pattern a] [Pattern a] 

Instances

Instances details
Show a => Show (Env a) Source # 
Instance details

Defined in Language.Change

Methods

showsPrec :: Int -> Env a -> ShowS #

show :: Env a -> String #

showList :: [Env a] -> ShowS #

testPatterns :: Ord a => [a] -> [Pattern a] -> Bool Source #

Match a list of phonemes against a list of patterns.

testEnv :: Ord a => [a] -> [a] -> Env a -> Bool Source #

Match two lists of phonemes against an Env.

Sound changes

newtype Change a Source #

A sound change.

Constructors

Change (Map a [([a], Env a)]) 

Instances

Instances details
Show a => Show (Change a) Source # 
Instance details

Defined in Language.Change

Methods

showsPrec :: Int -> Change a -> ShowS #

show :: Change a -> String #

showList :: [Change a] -> ShowS #

applyChange :: Ord a => Change a -> [a] -> [a] Source #

Apply a sound change to a word.

applyChanges :: Ord a => [Change a] -> [a] -> [a] Source #

Apply a sequence of sound changes to a word, returning the final result.

traceChanges :: Ord a => [Change a] -> [a] -> [[a]] Source #

Apply a sequence of sound changes to a word, returning a list of intermediate results. (The first element of the list is the original word, and the last element is the result after applying all changes.)

replace :: ([a] -> a -> [a] -> [b]) -> [a] -> [b] Source #

A helper function used by applyChange. Similar to map, except the first argument returns a list and has access to each element's environment.