Safe Haskell | Safe-Inferred |
---|
The Str
and Symbol
types, and ToExpr
class.
They are split into a module with few dependencies so modules can make exprs
without incurring a dependency on Derive.DeriveT, and specifically
Val
, which drags in tons of stuff.
Synopsis
- type Expr val = NonEmpty (Call val)
- data Call val = Call Symbol [Term val]
- data Term val
- show_val_expr :: ShowVal (Call val) => Expr val -> Text
- show_val_call :: ShowVal (Term val) => (val -> Maybe Text) -> Call val -> Text
- show_val_term :: (ShowVal val, ShowVal (Call val)) => Term val -> Text
- newtype Symbol = Symbol Text
- unsym :: Symbol -> Text
- expr :: [Call val] -> Call val -> Expr val
- generator :: Call val -> Expr val
- generator0 :: Symbol -> Expr val
- split :: Expr val -> ([Call val], Call val)
- call :: Symbol -> [val] -> Call val
- call0 :: Symbol -> Call val
- val_call :: Symbol -> [a] -> Term a
- transform :: Call a -> Expr a -> Expr a
- transform0 :: Symbol -> Expr a -> Expr a
- with :: ToExpr a => Symbol -> a -> Expr MiniVal
- str_to_scale_id :: Str -> Pitch.ScaleId
- scale_id_to_str :: Pitch.ScaleId -> Str
- map_symbol :: (Symbol -> Symbol) -> Call a -> Call a
- map_literals :: (a -> b) -> Expr a -> Expr b
- map_generator :: (Symbol -> Symbol) -> Expr a -> Expr a
- class ToExpr a where
- newtype Str = Str Text
- unstr :: Str -> Text
- data MiniVal
- = VNum !(ScoreT.Typed Signal.Y)
- | VStr !Str
- class ToVal a where
Documentation
type Expr val = NonEmpty (Call val) Source #
A full toplevel expression, sometimes called a "pipeline", because it looks
like "transform | transform | generator arg arg". Since the only operator
is |
, which is basically just application, a list suffices for an AST.
This is parameterized by the literal value, so a tokenized expr is
Expr Text
while fully parsed one would be Expr Val
.
Instances
Functor Call Source # | |
ToVal Expr Source # | |
Serialize.Serialize Call Source # | |
String.IsString (Call val) Source # | |
Defined in Derive.Expr fromString :: String.String -> Call val # | |
String.IsString (Expr val) Source # | |
Defined in Derive.Expr fromString :: String.String -> Expr val # | |
Read val => Read (Call val) Source # | |
Show val => Show (Call val) Source # | |
Eq val => Eq (Call val) Source # | |
ShowVal (Call Val) Source # | |
ShowVal (Call MiniVal) Source # | |
ShowVal (Call Text) Source # | |
ShowVal (Expr Val) Source # | |
ShowVal (Expr MiniVal) Source # | |
ShowVal (Expr Text) Source # | |
Pretty (Call Val) Source # | |
Pretty (Call MiniVal) Source # | |
Pretty (Call Text) Source # | |
Instances
Functor Term Source # | |
Serialize.Serialize Term Source # | |
Read val => Read (Term val) Source # | |
Show val => Show (Term val) Source # | |
Eq val => Eq (Term val) Source # | |
ShowVal (Term Val) Source # | |
ShowVal (Term MiniVal) Source # | |
ShowVal (Term Text) Source # | |
Pretty (Term Val) Source # | |
Pretty (Term MiniVal) Source # | |
Pretty (Term Text) Source # | |
Name of a call, used to look it up in the namespace.
This is parsed by Parse.p_call_symbol, so it can have any character except space, =, or ) for val calls. It's not enforced though, especially since there's an IsString instance, but if you put in a space you'll get a messed up expression.
Instances
String.IsString Symbol Source # | |
Defined in Derive.Expr fromString :: String.String -> Symbol # | |
Monoid Symbol Source # | |
Semigroup Symbol Source # | |
Read Symbol Source # | |
Show Symbol Source # | |
DeepSeq.NFData Symbol Source # | |
Defined in Derive.Expr | |
Eq Symbol Source # | |
Ord Symbol Source # | |
ShowVal Symbol Source # | |
ToVal Symbol Source # | |
Typecheck Symbol Source # | |
Pretty Symbol Source # | |
Serialize.Serialize Symbol Source # | |
generator0 :: Symbol -> Expr val Source #
Generator with no arguments.
split :: Expr val -> ([Call val], Call val) Source #
Split into (transformers, generator). Inverse of expr
.
transform
str_to_scale_id :: Str -> Pitch.ScaleId Source #
scale_id_to_str :: Pitch.ScaleId -> Str Source #
map_generator :: (Symbol -> Symbol) -> Expr a -> Expr a Source #
Transform only the Symbol in the generator position.
ToExpr
This is meant for types which can be turned into a tracklang expression. For example, drum strokes might have a parsed form which can be turned into calls.
Instances
ToExpr Bol Source # | |
ToExpr Stroke Source # | These have to match with Cmd.Instrument.KendangBali. |
ToExpr Stroke Source # | TODO should I make these consistent with |
ToExpr Stroke Source # | Pretty reproduces the Derive.Solkattu.Dsl syntax, which has to be
haskell syntax, so it can't use +, and I have to put thoppi first to avoid
the keyword |
ToExpr Stroke Source # | |
ToExpr Stroke Source # | |
ToExpr Pattern Source # | |
ToExpr Sollu Source # | |
ToExpr (Stroke Bol) Source # | |
ToExpr (Stroke Stroke) Source # | |
ToExpr (Stroke Stroke) Source # | |
ToExpr (Stroke Stroke) Source # | |
ToExpr (Stroke Stroke) Source # | |
ToExpr (Stroke Stroke) Source # | |
ToExpr (Stroke Sollu) Source # | |
Str
Instances
String.IsString Str Source # | |
Defined in Derive.Expr fromString :: String.String -> Str # | |
Read Str Source # | |
Show Str Source # | |
DeepSeq.NFData Str Source # | |
Defined in Derive.Expr | |
Eq Str Source # | |
Ord Str Source # | |
ToVal Str Source # | |
ShowVal Str Source # | |
ToVal Str Source # | |
Typecheck Str Source # | |
Pretty Str Source # | |
Serialize.Serialize Str Source # | |
MiniVal
Yes, it's yet another Val variant. This one is even more mini than REnv.Val. TODO NOTE [val-and-minival]
VNum !(ScoreT.Typed Signal.Y) | |
VStr !Str |
Instances
String.IsString MiniVal Source # | |
Defined in Derive.Expr fromString :: String.String -> MiniVal # | |
Show MiniVal Source # | |
Eq MiniVal Source # | |
Ord MiniVal Source # | |
ShowVal MiniVal Source # | |
Pretty MiniVal Source # | |
Serialize.Serialize MiniVal Source # | |
ShowVal (Call MiniVal) Source # | |
ShowVal (Expr MiniVal) Source # | |
ShowVal (Term MiniVal) Source # | |
Pretty (Call MiniVal) Source # | |
Pretty (Term MiniVal) Source # | |