Safe Haskell | Safe-Inferred |
---|
Derive.Typecheck
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 #
Constructors
RealTimeFunction !(RealTime.RealTime -> DeriveT.Duration) |
Instances
Typecheck RealTimeFunction Source # | |
Defined in Derive.Typecheck Methods from_val :: DeriveT.Val -> Checked RealTimeFunction Source # to_type :: Proxy RealTimeFunction -> ValType.Type Source # from_subtrack :: SubT.Track -> Maybe RealTimeFunction Source # |
data ScoreTimeFunction Source #
Constructors
ScoreTimeFunction !(RealTime.RealTime -> DeriveT.Duration) |
Instances
Typecheck ScoreTimeFunction Source # | |
Defined in Derive.Typecheck Methods from_val :: DeriveT.Val -> Checked ScoreTimeFunction Source # to_type :: Proxy ScoreTimeFunction -> ValType.Type Source # from_subtrack :: SubT.Track -> Maybe ScoreTimeFunction Source # |
data RealTimeFunctionT Source #
Returning them separately is used in (at least) Speed.starts
Constructors
RealTimeFunctionT !ScoreT.TimeT !ScoreT.Function |
Instances
Typecheck RealTimeFunctionT Source # | |
Defined in Derive.Typecheck Methods from_val :: DeriveT.Val -> Checked RealTimeFunctionT Source # to_type :: Proxy RealTimeFunctionT -> ValType.Type Source # from_subtrack :: SubT.Track -> Maybe RealTimeFunctionT Source # |
data ScoreTimeFunctionT Source #
Constructors
ScoreTimeFunctionT !ScoreT.TimeT !ScoreT.Function |
Instances
Typecheck ScoreTimeFunctionT Source # | |
Defined in Derive.Typecheck Methods from_val :: DeriveT.Val -> Checked ScoreTimeFunctionT Source # to_type :: Proxy ScoreTimeFunctionT -> ValType.Type Source # from_subtrack :: SubT.Track -> Maybe ScoreTimeFunctionT Source # |
data DiatonicTransposeFunctionT Source #
Constructors
DiatonicTransposeFunctionT !ScoreT.TransposeT !ScoreT.Function |
Instances
data ChromaticTransposeFunctionT Source #
Constructors
ChromaticTransposeFunctionT !ScoreT.TransposeT !ScoreT.Function |
Instances
data NnTransposeFunctionT Source #
Constructors
NnTransposeFunctionT !ScoreT.TransposeT !ScoreT.Function |
Instances
Typecheck NnTransposeFunctionT Source # | |
Defined in Derive.Typecheck Methods from_val :: DeriveT.Val -> Checked NnTransposeFunctionT Source # to_type :: Proxy NnTransposeFunctionT -> ValType.Type Source # from_subtrack :: SubT.Track -> Maybe NnTransposeFunctionT Source # |
type wrappers
newtype DefaultReal Source #
Either RealTime or ScoreTime, but untyped defaults to RealTime. This has a short accessor to make unwrapping more concise.
Constructors
DefaultReal | |
Fields |
Instances
Show DefaultReal Source # | |
Defined in Derive.Typecheck Methods showsPrec :: Int -> DefaultReal -> ShowS # show :: DefaultReal -> String # showList :: [DefaultReal] -> ShowS # | |
Eq DefaultReal Source # | |
Defined in Derive.Typecheck | |
Internal.Time DefaultReal Source # | |
Defined in Derive.Typecheck Methods real :: DefaultReal -> Derive.Deriver RealTime.RealTime Source # score :: DefaultReal -> Derive.Deriver ScoreTime.ScoreTime Source # | |
ShowVal.ShowVal DefaultReal Source # | |
Defined in Derive.Typecheck Methods show_val :: DefaultReal -> Text Source # | |
ToVal DefaultReal Source # | |
Defined in Derive.Typecheck Methods to_val :: DefaultReal -> DeriveT.Val Source # | |
Typecheck DefaultReal Source # | |
Defined in Derive.Typecheck Methods from_val :: DeriveT.Val -> Checked DefaultReal Source # to_type :: Proxy DefaultReal -> ValType.Type Source # | |
TypecheckNum DefaultReal Source # | |
Defined in Derive.Typecheck Methods |
newtype DefaultScore Source #
Same as DefaultReal
but untyped defaults to ScoreTime.
This has a short accessor to make unwrapping more concise.
Constructors
DefaultScore | |
Fields |
Instances
Show DefaultScore Source # | |
Defined in Derive.Typecheck Methods showsPrec :: Int -> DefaultScore -> ShowS # show :: DefaultScore -> String # showList :: [DefaultScore] -> ShowS # | |
Eq DefaultScore Source # | |
Defined in Derive.Typecheck | |
Internal.Time DefaultScore Source # | |
Defined in Derive.Typecheck | |
ShowVal.ShowVal DefaultScore Source # | |
Defined in Derive.Typecheck Methods show_val :: DefaultScore -> Text Source # | |
ToVal DefaultScore Source # | |
Defined in Derive.Typecheck Methods to_val :: DefaultScore -> DeriveT.Val Source # | |
Typecheck DefaultScore Source # | |
Defined in Derive.Typecheck Methods from_val :: DeriveT.Val -> Checked DefaultScore Source # to_type :: Proxy DefaultScore -> ValType.Type Source # | |
TypecheckNum DefaultScore Source # | |
Defined in Derive.Typecheck Methods |
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 Methods to_val :: Positive a -> DeriveT.Val Source # | |
TypecheckNum a => Typecheck (Positive a) Source # | |
Defined in Derive.Typecheck Methods 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.
Constructors
NonNegative | |
Fields
|
Instances
newtype Normalized Source #
0 <= x <= 1
Constructors
Normalized | |
Fields
|
Instances
Show Normalized Source # | |
Defined in Derive.Typecheck Methods showsPrec :: Int -> Normalized -> ShowS # show :: Normalized -> String # showList :: [Normalized] -> ShowS # | |
Eq Normalized Source # | |
Defined in Derive.Typecheck | |
ShowVal.ShowVal Normalized Source # | |
Defined in Derive.Typecheck Methods show_val :: Normalized -> Text Source # | |
ToVal Normalized Source # | |
Defined in Derive.Typecheck Methods to_val :: Normalized -> DeriveT.Val Source # | |
Typecheck Normalized Source # | |
Defined in Derive.Typecheck Methods from_val :: DeriveT.Val -> Checked Normalized Source # to_type :: Proxy Normalized -> ValType.Type Source # | |
Pretty Normalized Source # | |
Defined in Derive.Typecheck Methods pretty :: Normalized -> Text Source # format :: Normalized -> Doc Source # formatList :: [Normalized] -> Doc Source # |
newtype NormalizedBipolar Source #
- 1 <= x <= 1
Constructors
NormalizedBipolar | |
Fields |
Instances
newtype DefaultDiatonic Source #
Normally Transpose will default to Chromatic if the val is untyped, but some calls would prefer to default to Diatonic.
Constructors
DefaultDiatonic | |
Fields |
Instances
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.
Constructors
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. |
Constructors
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.
Minimal complete definition
Nothing
Methods
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
.
Minimal complete definition
Nothing
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 #
Methods
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.
compatibility
Orphan instances
ShowVal.ShowVal Meter.Rank Source # | |
Methods show_val :: Meter.Rank -> Text Source # |