| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
PVGrammar.Parse
Description
This module contains code that is specific to parsing the protovoice grammar.
It implements a number of evaluators (Eval) that can be used with the various parsers.
Synopsis
- type IsPitch n = (HasPitch n, Diatonic (ICOf (IntervalOf n)), Eq (ICOf (IntervalOf n)), Eq (IntervalOf n))
- protoVoiceEvaluator :: (Foldable t, Foldable t2, Eq n, Ord n, IsPitch n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 (Note n)) (Spread n) (PVLeftmost n)
- protoVoiceEvaluatorNoRepSplit :: (Foldable t, Foldable t2, Eq n, Ord n, IsPitch n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 (Note n)) (Spread n) (PVLeftmost n)
- pvDerivUnrestricted :: (Foldable t, Foldable t2, Eq n, Ord n, IsPitch n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 (Note n)) (Spread n) (Derivations (PVLeftmost n))
- pvDerivRightBranch :: (Foldable t, Foldable t2, Eq n, Ord n, IsPitch n, Notation n, Hashable n) => Eval (Merged, (RightBranchSpread, Edges n)) (t (Edge n)) ((), ((), Notes n)) (t2 (Note n)) ((), ((), Spread n)) (Derivations (PVLeftmost n))
- pvCountUnrestricted :: (Foldable t, Foldable t2, Eq n, Ord n, IsPitch n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 (Note n)) (Spread n) Int
- pvCountNoRepSplit :: (Foldable t, Foldable t2, Eq n, Ord n, IsPitch n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 (Note n)) (Spread n) Int
- pvCountNoRepSplitRightBranch :: (Foldable t, Foldable t2, Eq n, Ord n, IsPitch n, Notation n, Hashable n) => Eval (RightBranchSpread, Edges n) (t (Edge n)) ((), Notes n) (t2 (Note n)) ((), Spread n) Int
- pvCountNoRepSplitRightBranchSplitFirst :: (Foldable t, Foldable t2, Eq n, Ord n, IsPitch n, Notation n, Hashable n) => Eval (Merged, (RightBranchSpread, Edges n)) (t (Edge n)) ((), ((), Notes n)) (t2 (Note n)) ((), ((), Spread n)) Int
- pvThaw :: (Foldable t, Ord n, Hashable n) => Maybe (t (Edge n)) -> Edges n
Generic Parsing
Evaluators that directly return protovoice operations.
They can be embedded into a semiring using mapEvalScore.
type IsPitch n = (HasPitch n, Diatonic (ICOf (IntervalOf n)), Eq (ICOf (IntervalOf n)), Eq (IntervalOf n)) Source #
A constraint alias for note types.
protoVoiceEvaluator :: (Foldable t, Foldable t2, Eq n, Ord n, IsPitch n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 (Note n)) (Spread n) (PVLeftmost n) Source #
The evaluator that represents the proto-voice grammar.
As scores it returns a representation of each operation.
These scores do not form a semiring,
but can be embedded into different semirings using mapEvalScore.
protoVoiceEvaluatorNoRepSplit :: (Foldable t, Foldable t2, Eq n, Ord n, IsPitch n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 (Note n)) (Spread n) (PVLeftmost n) Source #
A restricted version of the PV evaluator that prohibits split operations in which one of the parent slices is repeated entirely.
Parsing Derivations
pvDerivUnrestricted :: (Foldable t, Foldable t2, Eq n, Ord n, IsPitch n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 (Note n)) (Spread n) (Derivations (PVLeftmost n)) Source #
An evaluator for protovoices that produces values in the Derivations semiring.
pvDerivRightBranch :: (Foldable t, Foldable t2, Eq n, Ord n, IsPitch n, Notation n, Hashable n) => Eval (Merged, (RightBranchSpread, Edges n)) (t (Edge n)) ((), ((), Notes n)) (t2 (Note n)) ((), ((), Spread n)) (Derivations (PVLeftmost n)) Source #
An evaluator for protovoices that produces values in the Derivations semiring.
- Enforces right-branching spreads (see
rightBranchSpread).
Counting Parses
pvCountUnrestricted :: (Foldable t, Foldable t2, Eq n, Ord n, IsPitch n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 (Note n)) (Spread n) Int Source #
An evaluator for protovoices that produces values in the counting semiring.
pvCountNoRepSplit :: (Foldable t, Foldable t2, Eq n, Ord n, IsPitch n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 (Note n)) (Spread n) Int Source #
An evaluator for protovoices that produces values in the counting semiring.
- Prohibits split operations in which one of the parent slices is repeated entirely (see
protoVoiceEvaluatorNoRepSplit).
pvCountNoRepSplitRightBranch :: (Foldable t, Foldable t2, Eq n, Ord n, IsPitch n, Notation n, Hashable n) => Eval (RightBranchSpread, Edges n) (t (Edge n)) ((), Notes n) (t2 (Note n)) ((), Spread n) Int Source #
An evaluator for protovoices that produces values in the counting semiring.
- Prohibits split operations in which one of the parent slices is repeated entirely (see
protoVoiceEvaluatorNoRepSplit). - Enforces right-branching spreads (see
rightBranchSpread).
pvCountNoRepSplitRightBranchSplitFirst :: (Foldable t, Foldable t2, Eq n, Ord n, IsPitch n, Notation n, Hashable n) => Eval (Merged, (RightBranchSpread, Edges n)) (t (Edge n)) ((), ((), Notes n)) (t2 (Note n)) ((), ((), Spread n)) Int Source #
An evaluator for protovoices that produces values in the counting semiring.
- Prohibits split operations in which one of the parent slices is repeated entirely (see
protoVoiceEvaluatorNoRepSplit). - Enforces right-branching spreads (see
rightBranchSpread). - Normalizes the order of adjacent split and spread operations to split-before-spread (see
splitFirst).