Safe Haskell | Safe-Inferred |
---|
Synopsis
- data RealTimeFunction = RealTimeFunction !(RealTime.RealTime -> DeriveT.Duration)
- data ScoreTimeFunction = ScoreTimeFunction !(RealTime.RealTime -> DeriveT.Duration)
- data RealTimeFunctionT = RealTimeFunctionT !ScoreT.TimeT !ScoreT.Function
- data ScoreTimeFunctionT = ScoreTimeFunctionT !ScoreT.TimeT !ScoreT.Function
- data DiatonicTransposeFunctionT = DiatonicTransposeFunctionT !ScoreT.TransposeT !ScoreT.Function
- data ChromaticTransposeFunctionT = ChromaticTransposeFunctionT !ScoreT.TransposeT !ScoreT.Function
- data NnTransposeFunctionT = NnTransposeFunctionT !ScoreT.TransposeT !ScoreT.Function
- newtype DefaultReal = DefaultReal {}
- newtype DefaultScore = DefaultScore {}
- real :: RealTime.RealTime -> DefaultReal
- score :: ScoreTime.ScoreTime -> DefaultScore
- newtype Positive a = Positive {
- positive :: a
- newtype NonNegative a = NonNegative {
- non_negative :: a
- newtype Normalized = Normalized {
- normalized :: Double
- newtype NormalizedBipolar = NormalizedBipolar {}
- newtype DefaultDiatonic = DefaultDiatonic {}
- diatonic :: Double -> DefaultDiatonic
- typecheck :: forall a. Typecheck a => Text -> ScoreTime.ScoreTime -> DeriveT.Val -> Derive.Deriver a
- typecheck_simple :: forall a. Typecheck a => DeriveT.Val -> Either Text a
- data Checked a
- = Val (Result a)
- | Eval (RealTime.RealTime -> Derive.Deriver (Maybe a))
- data Result a
- = Failure
- | Success !a
- | Derive !(Derive.Context Derive.Tagged -> a)
- success :: a -> Checked a
- failure :: Checked a
- class Typecheck a where
- from_val :: DeriveT.Val -> Checked a
- to_type :: Proxy a -> ValType.Type
- from_subtrack :: SubT.Track -> Maybe a
- from_val_eval :: Typecheck a => ScoreTime.ScoreTime -> DeriveT.Val -> Derive.Deriver (Maybe a)
- from_val_simple :: Typecheck a => DeriveT.Val -> Maybe a
- type TEnum a = (ShowVal.ShowVal a, Bounded a, Enum a)
- class ToVal a where
- to_val :: a -> DeriveT.Val
- to_type_symbol :: ShowVal.ShowVal a => [a] -> ValType.Type
- from_val_symbol :: Map Text a -> DeriveT.Val -> Checked a
- num_to_type :: TypecheckNum a => Proxy a -> ValType.Type
- class Typecheck a => TypecheckNum a where
- num_type :: Proxy a -> ValType.NumType
- to_transpose :: ScoreT.TransposeT -> Double -> Pitch.Transpose
- transpose_control :: ScoreT.TransposeT -> ScoreT.Control
- coerce_to_scalar :: (ScoreT.Typed Signal.Y -> Maybe a) -> DeriveT.Val -> Checked a
- lookup_function :: DeriveT.ControlRef -> Derive.Deriver (Maybe ScoreT.TypedFunction)
- lookup_signal :: ScoreT.Control -> Derive.Deriver (Maybe ScoreT.TypedSignal)
- val_to_signal :: DeriveT.Val -> Maybe (Either (Derive.Deriver ScoreT.TypedSignal) ScoreT.TypedSignal)
- val_to_function :: DeriveT.Val -> Maybe (Either (Derive.Deriver ScoreT.TypedFunction) ScoreT.TypedFunction)
- val_to_function_dyn :: DeriveT.Dynamic -> DeriveT.Val -> Maybe (Either (Derive.Deriver ScoreT.TypedFunction) ScoreT.TypedFunction)
- val_to_pitch_signal :: DeriveT.Val -> Maybe (Either (Derive.Deriver DeriveT.PSignal) DeriveT.PSignal)
- lookup_pitch_signal :: ScoreT.PControl -> Derive.Deriver (Maybe DeriveT.PSignal)
- resolve_pitch_ref :: DeriveT.PControlRef -> Derive.Deriver DeriveT.PSignal
- resolve_function :: DeriveT.ControlRef -> Derive.Deriver ScoreT.TypedFunction
signal functions
data RealTimeFunction Source #
Instances
Typecheck RealTimeFunction Source # | |
Defined in Derive.Typecheck |
data ScoreTimeFunction Source #
Instances
data RealTimeFunctionT Source #
Returning them separately is used in (at least) Speed.starts
Instances
data ScoreTimeFunctionT Source #
Instances
data DiatonicTransposeFunctionT Source #
Instances
data NnTransposeFunctionT Source #
Instances
type wrappers
newtype DefaultReal Source #
Either RealTime or ScoreTime, but untyped defaults to RealTime. This has a short accessor to make unwrapping more concise.
Instances
Show DefaultReal Source # | |
Defined in Derive.Typecheck showsPrec :: Int -> DefaultReal -> ShowS # show :: DefaultReal -> String # showList :: [DefaultReal] -> ShowS # | |
Eq DefaultReal Source # | |
Defined in Derive.Typecheck (==) :: DefaultReal -> DefaultReal -> Bool # (/=) :: DefaultReal -> DefaultReal -> Bool # | |
Internal.Time DefaultReal Source # | |
Defined in Derive.Typecheck | |
ShowVal.ShowVal DefaultReal Source # | |
Defined in Derive.Typecheck show_val :: DefaultReal -> Text Source # | |
ToVal DefaultReal Source # | |
Defined in Derive.Typecheck to_val :: DefaultReal -> DeriveT.Val Source # | |
Typecheck DefaultReal Source # | |
Defined in Derive.Typecheck from_val :: DeriveT.Val -> Checked DefaultReal Source # to_type :: Proxy DefaultReal -> ValType.Type Source # | |
TypecheckNum DefaultReal Source # | |
Defined in Derive.Typecheck |
newtype DefaultScore Source #
Same as DefaultReal
but untyped defaults to ScoreTime.
This has a short accessor to make unwrapping more concise.
Instances
Show DefaultScore Source # | |
Defined in Derive.Typecheck showsPrec :: Int -> DefaultScore -> ShowS # show :: DefaultScore -> String # showList :: [DefaultScore] -> ShowS # | |
Eq DefaultScore Source # | |
Defined in Derive.Typecheck (==) :: DefaultScore -> DefaultScore -> Bool # (/=) :: DefaultScore -> DefaultScore -> Bool # | |
Internal.Time DefaultScore Source # | |
Defined in Derive.Typecheck | |
ShowVal.ShowVal DefaultScore Source # | |
Defined in Derive.Typecheck show_val :: DefaultScore -> Text Source # | |
ToVal DefaultScore Source # | |
Defined in Derive.Typecheck to_val :: DefaultScore -> DeriveT.Val Source # | |
Typecheck DefaultScore Source # | |
Defined in Derive.Typecheck | |
TypecheckNum DefaultScore Source # | |
Defined in Derive.Typecheck |
real :: RealTime.RealTime -> DefaultReal Source #
Create DefaultReal and DefaultScores for use in Derive.Sig signatures for default values. It would be nice to use literals and let type inference do its thing, but there's no good definition for the rest of the methods in Integral and Fractional.
An annotation that says this value must be >0. Instances only exist for numeric types.
This is an instance of Num just so numeric literals work. Of course that means you also have (-) which can make it not positive, but this is only intended to be a type tag for signatures, unwrapped as soon as it gets passed to the call.
Instances
Num a => Num (Positive a) Source # | |
Defined in Derive.Typecheck | |
Fractional a => Fractional (Positive a) Source # | |
Show a => Show (Positive a) Source # | |
Eq a => Eq (Positive a) Source # | |
ShowVal.ShowVal a => ShowVal.ShowVal (Positive a) Source # | |
ToVal a => ToVal (Positive a) Source # | |
Defined in Derive.Typecheck to_val :: Positive a -> DeriveT.Val Source # | |
TypecheckNum a => Typecheck (Positive a) Source # | |
Defined in Derive.Typecheck from_val :: DeriveT.Val -> Checked (Positive a) Source # to_type :: Proxy (Positive a) -> ValType.Type Source # from_subtrack :: SubT.Track -> Maybe (Positive a) Source # |
newtype NonNegative a Source #
Like Positive, but also includes 0.
NonNegative | |
|
Instances
newtype Normalized Source #
0 <= x <= 1
Instances
Show Normalized Source # | |
Defined in Derive.Typecheck showsPrec :: Int -> Normalized -> ShowS # show :: Normalized -> String # showList :: [Normalized] -> ShowS # | |
Eq Normalized Source # | |
Defined in Derive.Typecheck (==) :: Normalized -> Normalized -> Bool # (/=) :: Normalized -> Normalized -> Bool # | |
ShowVal.ShowVal Normalized Source # | |
Defined in Derive.Typecheck show_val :: Normalized -> Text Source # | |
ToVal Normalized Source # | |
Defined in Derive.Typecheck to_val :: Normalized -> DeriveT.Val Source # | |
Typecheck Normalized Source # | |
Defined in Derive.Typecheck from_val :: DeriveT.Val -> Checked Normalized Source # to_type :: Proxy Normalized -> ValType.Type Source # | |
Pretty Normalized Source # | |
Defined in Derive.Typecheck pretty :: Normalized -> Text Source # format :: Normalized -> Doc Source # formatList :: [Normalized] -> Doc Source # |
newtype NormalizedBipolar Source #
- 1 <= x <= 1
Instances
Show NormalizedBipolar Source # | |
Defined in Derive.Typecheck showsPrec :: Int -> NormalizedBipolar -> ShowS # show :: NormalizedBipolar -> String # showList :: [NormalizedBipolar] -> ShowS # | |
Eq NormalizedBipolar Source # | |
Defined in Derive.Typecheck (==) :: NormalizedBipolar -> NormalizedBipolar -> Bool # (/=) :: NormalizedBipolar -> NormalizedBipolar -> Bool # | |
ShowVal.ShowVal NormalizedBipolar Source # | |
Defined in Derive.Typecheck show_val :: NormalizedBipolar -> Text Source # | |
ToVal NormalizedBipolar Source # | |
Defined in Derive.Typecheck | |
Typecheck NormalizedBipolar Source # | |
Defined in Derive.Typecheck | |
Pretty NormalizedBipolar Source # | |
Defined in Derive.Typecheck pretty :: NormalizedBipolar -> Text Source # format :: NormalizedBipolar -> Doc Source # formatList :: [NormalizedBipolar] -> Doc Source # |
newtype DefaultDiatonic Source #
Normally Transpose will default to Chromatic if the val is untyped, but some calls would prefer to default to Diatonic.
Instances
Show DefaultDiatonic Source # | |
Defined in Derive.Typecheck showsPrec :: Int -> DefaultDiatonic -> ShowS # show :: DefaultDiatonic -> String # showList :: [DefaultDiatonic] -> ShowS # | |
Eq DefaultDiatonic Source # | |
Defined in Derive.Typecheck (==) :: DefaultDiatonic -> DefaultDiatonic -> Bool # (/=) :: DefaultDiatonic -> DefaultDiatonic -> Bool # | |
ShowVal.ShowVal DefaultDiatonic Source # | |
Defined in Derive.Typecheck show_val :: DefaultDiatonic -> Text Source # | |
ToVal DefaultDiatonic Source # | |
Defined in Derive.Typecheck to_val :: DefaultDiatonic -> DeriveT.Val Source # | |
Typecheck DefaultDiatonic Source # | But some calls want to default to diatonic, not chromatic. |
Defined in Derive.Typecheck | |
TypecheckNum DefaultDiatonic Source # | |
Defined in Derive.Typecheck |
diatonic :: Double -> DefaultDiatonic Source #
typecheck
typecheck :: forall a. Typecheck a => Text -> ScoreTime.ScoreTime -> DeriveT.Val -> Derive.Deriver a Source #
Typecheck a single Val, and throw if it's the wrong type.
typecheck_simple :: forall a. Typecheck a => DeriveT.Val -> Either Text a Source #
Typecheck a simple value, with no evaluation. This means you can't get a deriver or coerce signal to a number.
Val (Result a) | |
Eval (RealTime.RealTime -> Derive.Deriver (Maybe a)) | This val needs to be evaluated to know if it will typecheck. The argument is the call start time. This is needed when coercing a function to a scalar, because I only know the value to check after calling the function. |
Failure | |
Success !a | |
Derive !(Derive.Context Derive.Tagged -> a) | This is a {Note,Control,Pitch}Deriver, which needs a Context to
evaluate. |
class Typecheck a where Source #
This is the class of values which can be converted to a Checked
. ToVal
is
the inverse transformation.
Nothing
from_val :: DeriveT.Val -> Checked a Source #
to_type :: Proxy a -> ValType.Type Source #
from_subtrack :: SubT.Track -> Maybe a Source #
Instances
from_val_eval :: Typecheck a => ScoreTime.ScoreTime -> DeriveT.Val -> Derive.Deriver (Maybe a) Source #
from_val
, but evaluate if it's an Eval.
from_val_simple :: Typecheck a => DeriveT.Val -> Maybe a Source #
type TEnum a = (ShowVal.ShowVal a, Bounded a, Enum a) Source #
I can automatically derive a Typecheck for enum types. So a simple enum can get a Typecheck by "just" deriving these plus Typecheck.
This is the inverse of Typecheck's from_val
.
Nothing
to_val :: a -> DeriveT.Val Source #
default to_val :: TEnum a => a -> DeriveT.Val Source #
Instances
to_type_symbol :: ShowVal.ShowVal a => [a] -> ValType.Type Source #
from_val_symbol :: Map Text a -> DeriveT.Val -> Checked a Source #
num_to_type :: TypecheckNum a => Proxy a -> ValType.Type Source #
class Typecheck a => TypecheckNum a where Source #
num_type :: Proxy a -> ValType.NumType Source #
Instances
util
controls
coerce_to_scalar :: (ScoreT.Typed Signal.Y -> Maybe a) -> DeriveT.Val -> Checked a Source #
Coerce any numeric value to a ScoreT.Typed Signal.Y, and check it against the given function.
lookup_function :: DeriveT.ControlRef -> Derive.Deriver (Maybe ScoreT.TypedFunction) Source #
Resolve a ref to a function, applying a CFunction if there is one.
lookup_signal :: ScoreT.Control -> Derive.Deriver (Maybe ScoreT.TypedSignal) Source #
As with lookup_pitch_function
, this should be in Deriver.Lib.
val_to_signal :: DeriveT.Val -> Maybe (Either (Derive.Deriver ScoreT.TypedSignal) ScoreT.TypedSignal) Source #
val_to_function :: DeriveT.Val -> Maybe (Either (Derive.Deriver ScoreT.TypedFunction) ScoreT.TypedFunction) Source #
val_to_function_dyn :: DeriveT.Dynamic -> DeriveT.Val -> Maybe (Either (Derive.Deriver ScoreT.TypedFunction) ScoreT.TypedFunction) Source #
Unfortunately Internal.get_control_function_dynamic is non-trivial, so it makes sense to do it only once when converting many.
TODO does it really? It seems like a bogus tradeoff to have to make. I could cache it, but is that not what this is? If it's cheap to call Internal.get_control_function_dynamic and only expensive to force it, then I should always pass it, and rely on laziness.
pitch signals
val_to_pitch_signal :: DeriveT.Val -> Maybe (Either (Derive.Deriver DeriveT.PSignal) DeriveT.PSignal) Source #
lookup_pitch_signal :: ScoreT.PControl -> Derive.Deriver (Maybe DeriveT.PSignal) Source #
This should be in Deriver.Lib, but has to be here so the instance Typecheck PitchFunction can be declared here and avoid circular import.
resolve_pitch_ref :: DeriveT.PControlRef -> Derive.Deriver DeriveT.PSignal Source #
This is the pitch version of resolve_control_ref
, except simpler
because there's no pitch equivalent of CFunction.