Safe Haskell | Safe-Inferred |
---|---|
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 IsNote n = (HasPitch n, Diatonic (ICOf (IntervalOf n)), Eq (ICOf (IntervalOf n)))
- protoVoiceEvaluator :: (Foldable t, Foldable t2, Eq n, Ord n, IsNote n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 n) (PVLeftmost n)
- protoVoiceEvaluatorNoRepSplit :: (Foldable t, Foldable t2, Eq n, Ord n, IsNote n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 n) (PVLeftmost n)
- pvDerivUnrestricted :: (Foldable t, Foldable t2, Eq n, Ord n, IsNote n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 n) (Derivations (PVLeftmost n))
- pvDerivRightBranch :: (Foldable t, Foldable t2, Eq n, Ord n, IsNote n, Notation n, Hashable n) => Eval (Merged, (RightBranchSpread, Edges n)) (t (Edge n)) ((), ((), Notes n)) (t2 n) (Derivations (PVLeftmost n))
- pvCountUnrestricted :: (Foldable t, Foldable t2, Eq n, Ord n, IsNote n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 n) Int
- pvCountNoRepSplit :: (Foldable t, Foldable t2, Eq n, Ord n, IsNote n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 n) Int
- pvCountNoRepSplitRightBranch :: (Foldable t, Foldable t2, Eq n, Ord n, IsNote n, Notation n, Hashable n) => Eval (RightBranchSpread, Edges n) (t (Edge n)) ((), Notes n) (t2 n) Int
- pvCountNoRepSplitRightBranchSplitFirst :: (Foldable t, Foldable t2, Eq n, Ord n, IsNote n, Notation n, Hashable n) => Eval (Merged, (RightBranchSpread, Edges n)) (t (Edge n)) ((), ((), Notes n)) (t2 n) Int
Generic Parsing
Evaluators that directly return protovoice operations.
They can be embedded into a semiring using mapEvalScore
.
type IsNote n = (HasPitch n, Diatonic (ICOf (IntervalOf n)), Eq (ICOf (IntervalOf n))) Source #
A constraint alias for note types.
protoVoiceEvaluator :: (Foldable t, Foldable t2, Eq n, Ord n, IsNote n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 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, IsNote n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 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, IsNote n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 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, IsNote n, Notation n, Hashable n) => Eval (Merged, (RightBranchSpread, Edges n)) (t (Edge n)) ((), ((), Notes n)) (t2 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, IsNote n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 n) Int Source #
An evaluator for protovoices that produces values in the counting semiring.
pvCountNoRepSplit :: (Foldable t, Foldable t2, Eq n, Ord n, IsNote n, Notation n, Hashable n) => Eval (Edges n) (t (Edge n)) (Notes n) (t2 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, IsNote n, Notation n, Hashable n) => Eval (RightBranchSpread, Edges n) (t (Edge n)) ((), Notes n) (t2 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, IsNote n, Notation n, Hashable n) => Eval (Merged, (RightBranchSpread, Edges n)) (t (Edge n)) ((), ((), Notes n)) (t2 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
).