Safe Haskell | Safe-Inferred |
---|
This has the higher level parts of the deriver library. That is, functions where are considered basic but can be defined outside of Derive.Deriver.Monad.
Synopsis
- data Result = Result {}
- derive :: Constant -> Dynamic -> Deriver a -> RunResult a
- extract_result :: RunResult (Stream.Stream Score.Event) -> Result
- with_default_imported :: Deriver a -> Deriver a
- require :: HasCallStack => Text -> Maybe.Maybe a -> Deriver a
- require_right :: HasCallStack => (err -> Text) -> Either.Either err a -> Deriver a
- catch :: Bool -> Deriver a -> Deriver (Maybe.Maybe a)
- get_stack :: Deriver Stack.Stack
- real_function :: Deriver (ScoreTime -> RealTime)
- score_function :: Deriver (RealTime -> ScoreTime)
- with_imported :: Bool -> Module.Module -> Deriver a -> Deriver a
- with_imported_symbols :: Module.Module -> Set Expr.Symbol -> Deriver a -> Deriver a
- with_scopes :: (Scopes -> Scopes) -> Deriver a -> Deriver a
- get_scale :: Pitch.ScaleId -> Deriver Scale
- lookup_scale :: Pitch.ScaleId -> Deriver (Maybe.Maybe Scale)
- lookup_val :: Typecheck.Typecheck a => EnvKey.Key -> Deriver (Maybe.Maybe a)
- is_val_set :: EnvKey.Key -> Deriver Bool
- get_val :: Typecheck.Typecheck a => EnvKey.Key -> Deriver a
- with_val :: Typecheck.ToVal val => EnvKey.Key -> val -> Deriver a -> Deriver a
- with_vals :: Typecheck.ToVal val => [(EnvKey.Key, val)] -> Deriver a -> Deriver a
- with_environ :: DeriveT.Environ -> Deriver a -> Deriver a
- with_val_raw :: Typecheck.ToVal val => EnvKey.Key -> val -> Deriver a -> Deriver a
- remove_val :: EnvKey.Key -> Deriver a -> Deriver a
- remove_vals :: [EnvKey.Key] -> Deriver a -> Deriver a
- modify_val :: (Typecheck.Typecheck val, Typecheck.ToVal val) => EnvKey.Key -> (Maybe.Maybe val -> val) -> Deriver a -> Deriver a
- with_scale :: Scale -> Deriver d -> Deriver d
- with_instrument :: ScoreT.Instrument -> Deriver d -> Deriver d
- with_instrument_alias :: ScoreT.Instrument -> ScoreT.Instrument -> Deriver a -> Deriver a
- with_instrument_aliases :: Map ScoreT.Instrument ScoreT.Instrument -> Deriver a -> Deriver a
- instrument_exists :: ScoreT.Instrument -> Deriver Bool
- get_instrument :: ScoreT.Instrument -> Deriver (ScoreT.Instrument, Instrument)
- lookup_instrument :: ScoreT.Instrument -> Deriver (ScoreT.Instrument, Either.Either Text Instrument)
- lookup_signal :: ScoreT.Control -> Deriver (Maybe.Maybe (ScoreT.Typed Signal.Control))
- lookup_function :: ScoreT.Control -> Deriver (Maybe.Maybe ScoreT.TypedFunction)
- get_function :: ScoreT.Control -> Deriver ScoreT.TypedFunction
- is_control_set :: ScoreT.Control -> Deriver Bool
- get_control_map :: Deriver ScoreT.ControlMap
- get_function_map :: Deriver ScoreT.FunctionMap
- control_at :: ScoreT.Control -> RealTime -> Deriver (Maybe.Maybe (ScoreT.Typed Signal.Y))
- untyped_control_at :: ScoreT.Control -> RealTime -> Deriver (Maybe.Maybe Signal.Y)
- controls_at :: RealTime -> Deriver ScoreT.ControlValMap
- modify_signals :: (Signal.Control -> Signal.Control) -> (DeriveT.PSignal -> DeriveT.PSignal) -> Deriver a -> Deriver a
- with_control :: ScoreT.Control -> ScoreT.Typed Signal.Control -> Deriver a -> Deriver a
- with_constant_control :: ScoreT.Control -> Signal.Y -> Deriver a -> Deriver a
- with_controls :: [(ScoreT.Control, ScoreT.Typed Signal.Control)] -> Deriver a -> Deriver a
- remove_controls :: [ScoreT.Control] -> Deriver a -> Deriver a
- with_merged_control :: Merger -> ScoreT.Control -> ScoreT.Typed Signal.Control -> Deriver a -> Deriver a
- with_merged_controls :: [(ScoreT.Control, ScoreT.Typed Signal.Control)] -> Deriver a -> Deriver a
- resolve_merge :: Merge -> ScoreT.Control -> Deriver Merger
- get_control_merge :: Expr.Symbol -> Deriver Merger
- get_default_merger :: ScoreT.Control -> Deriver Merger
- modify_control :: Merger -> ScoreT.Control -> Signal.Control -> Deriver ()
- eval_control_mods :: RealTime -> Deriver a -> Deriver a
- with_control_mods :: [ControlMod] -> RealTime -> Deriver a -> Deriver a
- pitch_at :: RealTime -> Deriver (Maybe.Maybe DeriveT.Pitch)
- named_pitch_at :: ScoreT.PControl -> RealTime -> Deriver (Maybe.Maybe DeriveT.Pitch)
- resolve_pitch :: RealTime -> DeriveT.Pitch -> Deriver DeriveT.Transposed
- nn_at :: RealTime -> Deriver (Maybe.Maybe Pitch.NoteNumber)
- get_pitch :: Deriver DeriveT.PSignal
- named_nn_at :: ScoreT.PControl -> RealTime -> Deriver (Maybe.Maybe Pitch.NoteNumber)
- lookup_pitch_signal :: ScoreT.PControl -> Deriver (Maybe.Maybe DeriveT.PSignal)
- logged_pitch_nn :: Text -> DeriveT.Transposed -> Deriver (Maybe.Maybe Pitch.NoteNumber)
- with_pitch :: DeriveT.PSignal -> Deriver a -> Deriver a
- with_named_pitch :: ScoreT.PControl -> DeriveT.PSignal -> Deriver a -> Deriver a
- with_constant_pitch :: DeriveT.Pitch -> Deriver a -> Deriver a
- remove_pitch :: Deriver a -> Deriver a
- run_logs :: Log.LogId a -> Deriver a
- get_mode :: Deriver Mode
- is_lilypond_mode :: Deriver Bool
- lookup_lilypond_config :: Deriver (Maybe.Maybe Lilypond.Types.Config)
- get_score_duration :: Deriver a -> Deriver (Either.Either Error (CallDuration ScoreTime))
- get_real_duration :: Deriver a -> Deriver (Either.Either Error (CallDuration RealTime))
- with_event :: Score.Event -> Deriver a -> Deriver (Maybe.Maybe a)
- with_event_stack :: Score.Event -> Deriver a -> Deriver a
- shift_controls :: ScoreTime -> Deriver a -> Deriver a
- val_call :: Typecheck.ToVal a => Module.Module -> CallName -> Tags.Tags -> Doc.Doc -> WithArgDoc (PassedArgs Tagged -> Deriver a) -> ValCall
- set_module :: Module.Module -> Call f -> Call f
Documentation
Package up the results of a derivation.
Result | |
|
with_default_imported :: Deriver a -> Deriver a Source #
errors
require :: HasCallStack => Text -> Maybe.Maybe a -> Deriver a Source #
require_right :: HasCallStack => (err -> Text) -> Either.Either err a -> Deriver a Source #
:: Bool | If True, incorporate the evaluated |
-> Deriver a | |
-> Deriver (Maybe.Maybe a) |
If the deriver throws, log the error and return Nothing.
state access
import
with_imported :: Bool -> Module.Module -> Deriver a -> Deriver a Source #
Merge calls from the given module into scope.
with_imported_symbols :: Module.Module -> Set Expr.Symbol -> Deriver a -> Deriver a Source #
Import only the given symbols from the module.
with_scopes :: (Scopes -> Scopes) -> Deriver a -> Deriver a Source #
Run the derivation with a modified scope.
scale
lookup_scale :: Pitch.ScaleId -> Deriver (Maybe.Maybe Scale) Source #
environment
lookup_val :: Typecheck.Typecheck a => EnvKey.Key -> Deriver (Maybe.Maybe a) Source #
is_val_set :: EnvKey.Key -> Deriver Bool Source #
get_val :: Typecheck.Typecheck a => EnvKey.Key -> Deriver a Source #
Like lookup_val
, but throw if the value isn't present.
with_val :: Typecheck.ToVal val => EnvKey.Key -> val -> Deriver a -> Deriver a Source #
Set the given val dynamically within the given computation. This is analogous to a dynamic let.
Remove on VNotGiven, which is what any Nothing will become. There's no use
for a VNotGiven in the environ. The main way this is used is the val=_
c_equal syntax.
There is intentionally no way to modify the environment via assignment. It would introduce an order of execution dependency that would complicate caching as well as have a confusing non-local effect.
This dispatches to with_scale
or with_instrument
if it's setting the
scale or instrument, so scale or instrument scopes are always set when scale
and instrument are.
with_vals :: Typecheck.ToVal val => [(EnvKey.Key, val)] -> Deriver a -> Deriver a Source #
Like with_val
, but should be slightly more efficient for setting
multiple values at once.
with_environ :: DeriveT.Environ -> Deriver a -> Deriver a Source #
Merge the given environ into the environ in effect. Unlike with_val
or
with_vals
, this won't set scopes for EnvKey.scale
and
EnvKey.instrument
.
with_val_raw :: Typecheck.ToVal val => EnvKey.Key -> val -> Deriver a -> Deriver a Source #
Like with_val
, but don't set scopes for instrument and scale. Also
don't check for types, so you can replace a val with one of a different
type. Due to this it's also more efficient.
remove_val :: EnvKey.Key -> Deriver a -> Deriver a Source #
remove_vals :: [EnvKey.Key] -> Deriver a -> Deriver a Source #
modify_val :: (Typecheck.Typecheck val, Typecheck.ToVal val) => EnvKey.Key -> (Maybe.Maybe val -> val) -> Deriver a -> Deriver a Source #
with_scale :: Scale -> Deriver d -> Deriver d Source #
Replace the scale's calls.
Previously this used add_priority
instead of replace_priority
, which
meant you could overlay scales and use both at the same time. Maybe that's
actually a useful feature? In any case, I don't need it at the moment, so
it seems more likely to be confusing than useful.
with_instrument :: ScoreT.Instrument -> Deriver d -> Deriver d Source #
Run the a deriver with the given instrument in scope. In addition to
assigning the instrument to the EnvKey.instrument
field where note calls
can inherit it, this also brings the Instrument
fields into scope, which
is the per-instrument calls and per-instrument environ.
with_instrument_alias :: ScoreT.Instrument -> ScoreT.Instrument -> Deriver a -> Deriver a Source #
with_instrument_aliases :: Map ScoreT.Instrument ScoreT.Instrument -> Deriver a -> Deriver a Source #
lookup_instrument :: ScoreT.Instrument -> Deriver (ScoreT.Instrument, Either.Either Text Instrument) Source #
Look up the instrument. Also return the instrument name after resolving
any alias. This is what goes in Score.event_instrument
, since it's what
the performer understands.
control
get_function_map :: Deriver ScoreT.FunctionMap Source #
Like get_function
, but get them all.
control_at :: ScoreT.Control -> RealTime -> Deriver (Maybe.Maybe (ScoreT.Typed Signal.Y)) Source #
Get the control value at the given time.
controls_at :: RealTime -> Deriver ScoreT.ControlValMap Source #
Get a ControlValMap at the given time.
modify_signals :: (Signal.Control -> Signal.Control) -> (DeriveT.PSignal -> DeriveT.PSignal) -> Deriver a -> Deriver a Source #
Modify all VSignal and VPSignal types in environ.
control signal
with_control :: ScoreT.Control -> ScoreT.Typed Signal.Control -> Deriver a -> Deriver a Source #
with_constant_control :: ScoreT.Control -> Signal.Y -> Deriver a -> Deriver a Source #
with_controls :: [(ScoreT.Control, ScoreT.Typed Signal.Control)] -> Deriver a -> Deriver a Source #
remove_controls :: [ScoreT.Control] -> Deriver a -> Deriver a Source #
Remove both controls and control functions. Use this when a control has already been applied, and you don't want it to affect further derivation.
with_merged_control :: Merger -> ScoreT.Control -> ScoreT.Typed Signal.Control -> Deriver a -> Deriver a Source #
Modify the given control according to the Merger.
If both signals are typed, the existing type wins over the relative signal's type. If one is untyped, the typed one wins.
As documented in merge
, this acts like a Set if there is no existing
control.
with_merged_controls :: [(ScoreT.Control, ScoreT.Typed Signal.Control)] -> Deriver a -> Deriver a Source #
Like with_controls
, but merge them with their respective default
Merger
s.
resolve_merge :: Merge -> ScoreT.Control -> Deriver Merger Source #
get_default_merger :: ScoreT.Control -> Deriver Merger Source #
Get the default merger for this control, or merge_mul
if there is none.
ControlMod
modify_control :: Merger -> ScoreT.Control -> Signal.Control -> Deriver () Source #
Emit a ControlMod
.
:: RealTime | Trim controls to end at this time.
If a ControlMod is local to a slice it should end when the slice ends,
and since it bypasses |
-> Deriver a | |
-> Deriver a |
Apply the collected control mods to the given deriver and clear them out.
with_control_mods :: [ControlMod] -> RealTime -> Deriver a -> Deriver a Source #
pitch
pitch_at :: RealTime -> Deriver (Maybe.Maybe DeriveT.Pitch) Source #
The pitch at the given time. The transposition controls have not been applied since that is supposed to be done once only when the event is generated.
The scenario is a call that generates a note based on the current pitch.
If pitch_at
applied the transposition, the new note would have to remove
the transposition signals so they don't get applied again at performance
conversion.
named_pitch_at :: ScoreT.PControl -> RealTime -> Deriver (Maybe.Maybe DeriveT.Pitch) Source #
Like pitch_at
, this is a raw pitch.
resolve_pitch :: RealTime -> DeriveT.Pitch -> Deriver DeriveT.Transposed Source #
Resolve the raw pitch returned from pitch_at
to the final transposed
pitch.
nn_at :: RealTime -> Deriver (Maybe.Maybe Pitch.NoteNumber) Source #
Unlike pitch_at
, the transposition has already been applied, because you
can't transpose any further once you have a NoteNumber.
lookup_pitch_signal :: ScoreT.PControl -> Deriver (Maybe.Maybe DeriveT.PSignal) Source #
Re-export Typecheck.lookup_pitch_signal
, defined there to avoid
circular import.
logged_pitch_nn :: Text -> DeriveT.Transposed -> Deriver (Maybe.Maybe Pitch.NoteNumber) Source #
Version of DeriveT.pitch_nn
that logs errors.
with signal
with_pitch :: DeriveT.PSignal -> Deriver a -> Deriver a Source #
with_named_pitch :: ScoreT.PControl -> DeriveT.PSignal -> Deriver a -> Deriver a Source #
with_constant_pitch :: DeriveT.Pitch -> Deriver a -> Deriver a Source #
remove_pitch :: Deriver a -> Deriver a Source #
run monad
run_logs :: Log.LogId a -> Deriver a Source #
Embed a LogId into Deriver. This is for computations that need logging but not a full Deriver.
Mode
get_score_duration :: Deriver a -> Deriver (Either.Either Error (CallDuration ScoreTime)) Source #
Get the CallDuration
of the given deriver.
get_real_duration :: Deriver a -> Deriver (Either.Either Error (CallDuration RealTime)) Source #
postproc
with_event :: Score.Event -> Deriver a -> Deriver (Maybe.Maybe a) Source #
A combination of catch
and with_event_stack
.
with_event_stack :: Score.Event -> Deriver a -> Deriver a Source #
Replace the state_stack
with the one from the event. This is useful
for transformers, so they can show a stack trace to the event they are
processing.
shift_controls :: ScoreTime -> Deriver a -> Deriver a Source #
Shift the controls of a deriver. You're supposed to apply the warp before deriving the controls, but I don't have a good solution for how to do this yet, so I can leave these here for the moment.
call
val_call :: Typecheck.ToVal a => Module.Module -> CallName -> Tags.Tags -> Doc.Doc -> WithArgDoc (PassedArgs Tagged -> Deriver a) -> ValCall Source #
Wrap make_val_call
with a Typecheck.to_val
to automatically convert
to a DeriveT.Val
. This is not in Derive.Deriver.Monad to avoid
a circular import with Derive.DeriveT.
set_module :: Module.Module -> Call f -> Call f Source #