Karya, built on 2023-08-29T07:47:28 (patch 7a412d5d6ba4968ca4155ef276a062ccdeb9109a)
Safe HaskellSafe-Inferred

Derive.Expr

Description

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

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.

data Call val Source #

Constructors

Call Symbol [Term val] 

Instances

Instances details
Functor Call Source # 
Instance details

Defined in Derive.Expr

Methods

fmap :: (a -> b) -> Call a -> Call b #

(<$) :: a -> Call b -> Call a #

ToVal Expr Source # 
Instance details

Defined in Derive.REnv

Methods

to_val :: Expr -> Val Source #

Serialize.Serialize Call Source # 
Instance details

Defined in Derive.REnv

String.IsString (Call val) Source # 
Instance details

Defined in Derive.Expr

Methods

fromString :: String.String -> Call val #

String.IsString (Expr val) Source # 
Instance details

Defined in Derive.Expr

Methods

fromString :: String.String -> Expr val #

Read val => Read (Call val) Source # 
Instance details

Defined in Derive.Expr

Methods

readsPrec :: Int -> ReadS (Call val) #

readList :: ReadS [Call val] #

readPrec :: ReadPrec (Call val) #

readListPrec :: ReadPrec [Call val] #

Show val => Show (Call val) Source # 
Instance details

Defined in Derive.Expr

Methods

showsPrec :: Int -> Call val -> ShowS #

show :: Call val -> String.String #

showList :: [Call val] -> ShowS #

Eq val => Eq (Call val) Source # 
Instance details

Defined in Derive.Expr

Methods

(==) :: Call val -> Call val -> Bool #

(/=) :: Call val -> Call val -> Bool #

ShowVal (Call Val) Source # 
Instance details

Defined in Derive.DeriveT

Methods

show_val :: Call Val -> Text Source #

ShowVal (Call MiniVal) Source # 
Instance details

Defined in Derive.Expr

ShowVal (Call Text) Source # 
Instance details

Defined in Derive.Expr

Methods

show_val :: Call Text -> Text Source #

ShowVal (Expr Val) Source # 
Instance details

Defined in Derive.DeriveT

Methods

show_val :: Expr Val -> Text Source #

ShowVal (Expr MiniVal) Source # 
Instance details

Defined in Derive.Expr

ShowVal (Expr Text) Source # 
Instance details

Defined in Derive.Expr

Methods

show_val :: Expr Text -> Text Source #

Pretty (Call Val) Source # 
Instance details

Defined in Derive.DeriveT

Pretty (Call MiniVal) Source # 
Instance details

Defined in Derive.Expr

Pretty (Call Text) Source # 
Instance details

Defined in Derive.Expr

data Term val Source #

Constructors

ValCall (Call val) 
Literal val 

Instances

Instances details
Functor Term Source # 
Instance details

Defined in Derive.Expr

Methods

fmap :: (a -> b) -> Term a -> Term b #

(<$) :: a -> Term b -> Term a #

Serialize.Serialize Term Source # 
Instance details

Defined in Derive.REnv

Read val => Read (Term val) Source # 
Instance details

Defined in Derive.Expr

Methods

readsPrec :: Int -> ReadS (Term val) #

readList :: ReadS [Term val] #

readPrec :: ReadPrec (Term val) #

readListPrec :: ReadPrec [Term val] #

Show val => Show (Term val) Source # 
Instance details

Defined in Derive.Expr

Methods

showsPrec :: Int -> Term val -> ShowS #

show :: Term val -> String.String #

showList :: [Term val] -> ShowS #

Eq val => Eq (Term val) Source # 
Instance details

Defined in Derive.Expr

Methods

(==) :: Term val -> Term val -> Bool #

(/=) :: Term val -> Term val -> Bool #

ShowVal (Term Val) Source # 
Instance details

Defined in Derive.DeriveT

Methods

show_val :: Term Val -> Text Source #

ShowVal (Term MiniVal) Source # 
Instance details

Defined in Derive.Expr

ShowVal (Term Text) Source # 
Instance details

Defined in Derive.Expr

Methods

show_val :: Term Text -> Text Source #

Pretty (Term Val) Source # 
Instance details

Defined in Derive.DeriveT

Pretty (Term MiniVal) Source # 
Instance details

Defined in Derive.Expr

Pretty (Term Text) Source # 
Instance details

Defined in Derive.Expr

show_val_call :: ShowVal (Term val) => (val -> Maybe Text) -> Call val -> Text Source #

show_val_term :: (ShowVal val, ShowVal (Call val)) => Term val -> Text Source #

newtype Symbol 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.

Constructors

Symbol Text 

Instances

Instances details
String.IsString Symbol Source # 
Instance details

Defined in Derive.Expr

Monoid Symbol Source # 
Instance details

Defined in Derive.Expr

Semigroup Symbol Source # 
Instance details

Defined in Derive.Expr

Read Symbol Source # 
Instance details

Defined in Derive.Expr

Show Symbol Source # 
Instance details

Defined in Derive.Expr

DeepSeq.NFData Symbol Source # 
Instance details

Defined in Derive.Expr

Methods

rnf :: Symbol -> () #

Eq Symbol Source # 
Instance details

Defined in Derive.Expr

Methods

(==) :: Symbol -> Symbol -> Bool #

(/=) :: Symbol -> Symbol -> Bool #

Ord Symbol Source # 
Instance details

Defined in Derive.Expr

ShowVal Symbol Source # 
Instance details

Defined in Derive.Expr

Methods

show_val :: Symbol -> Text Source #

ToVal Symbol Source # 
Instance details

Defined in Derive.Typecheck

Methods

to_val :: Symbol -> Val Source #

Typecheck Symbol Source # 
Instance details

Defined in Derive.Typecheck

Pretty Symbol Source # 
Instance details

Defined in Derive.Expr

Serialize.Serialize Symbol Source # 
Instance details

Defined in Derive.Expr

expr :: [Call val] -> Call val -> Expr val Source #

generator :: Call val -> Expr val 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.

call :: Symbol -> [val] -> Call val Source #

Make a Call with Literal args.

val_call :: Symbol -> [a] -> Term a Source #

transform :: Call a -> Expr a -> Expr a Source #

with :: ToExpr a => Symbol -> a -> Expr MiniVal Source #

Shortcut to transform an Expr.

transform

map_literals :: (a -> b) -> Expr a -> Expr b Source #

Transform the Literals in an expression.

map_generator :: (Symbol -> Symbol) -> Expr a -> Expr a Source #

Transform only the Symbol in the generator position.

ToExpr

class ToExpr a where Source #

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.

Methods

to_expr :: a -> Expr MiniVal Source #

Instances

Instances details
ToExpr Bol Source # 
Instance details

Defined in Solkattu.Bol

ToExpr Stroke Source #

These have to match with Cmd.Instrument.KendangBali.

Instance details

Defined in Solkattu.Instrument.KendangPasang

ToExpr Stroke Source #

TODO should I make these consistent with Strokes?

Instance details

Defined in Solkattu.Instrument.KendangTunggal

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 do. It would be nice if I could make the tracklang syntax consistent, but maybe not a huge deal at the moment.

Instance details

Defined in Solkattu.Instrument.Mridangam

ToExpr Stroke Source # 
Instance details

Defined in Solkattu.Instrument.Reyong

ToExpr Stroke Source # 
Instance details

Defined in Solkattu.Instrument.Sargam

ToExpr Pattern Source # 
Instance details

Defined in Solkattu.Solkattu

ToExpr Sollu Source # 
Instance details

Defined in Solkattu.Instrument.Konnakol

ToExpr (Stroke Bol) Source # 
Instance details

Defined in Solkattu.Bol

ToExpr (Stroke Stroke) Source # 
Instance details

Defined in Solkattu.Instrument.KendangPasang

ToExpr (Stroke Stroke) Source # 
Instance details

Defined in Solkattu.Instrument.KendangTunggal

ToExpr (Stroke Stroke) Source # 
Instance details

Defined in Solkattu.Instrument.Mridangam

ToExpr (Stroke Stroke) Source # 
Instance details

Defined in Solkattu.Instrument.Reyong

ToExpr (Stroke Stroke) Source # 
Instance details

Defined in Solkattu.Instrument.Sargam

ToExpr (Stroke Sollu) Source # 
Instance details

Defined in Solkattu.Instrument.Konnakol

Str

newtype Str Source #

Constructors

Str Text 

Instances

Instances details
String.IsString Str Source # 
Instance details

Defined in Derive.Expr

Read Str Source # 
Instance details

Defined in Derive.Expr

Show Str Source # 
Instance details

Defined in Derive.Expr

Methods

showsPrec :: Int -> Str -> ShowS #

show :: Str -> String.String #

showList :: [Str] -> ShowS #

DeepSeq.NFData Str Source # 
Instance details

Defined in Derive.Expr

Methods

rnf :: Str -> () #

Eq Str Source # 
Instance details

Defined in Derive.Expr

Methods

(==) :: Str -> Str -> Bool #

(/=) :: Str -> Str -> Bool #

Ord Str Source # 
Instance details

Defined in Derive.Expr

Methods

compare :: Str -> Str -> Ordering #

(<) :: Str -> Str -> Bool #

(<=) :: Str -> Str -> Bool #

(>) :: Str -> Str -> Bool #

(>=) :: Str -> Str -> Bool #

max :: Str -> Str -> Str #

min :: Str -> Str -> Str #

ToVal Str Source # 
Instance details

Defined in Derive.REnv

Methods

to_val :: Str -> Val Source #

ShowVal Str Source # 
Instance details

Defined in Derive.Expr

Methods

show_val :: Str -> Text Source #

ToVal Str Source # 
Instance details

Defined in Derive.Typecheck

Methods

to_val :: Str -> Val Source #

Typecheck Str Source # 
Instance details

Defined in Derive.Typecheck

Pretty Str Source # 
Instance details

Defined in Derive.Expr

Serialize.Serialize Str Source # 
Instance details

Defined in Derive.Expr

MiniVal

data MiniVal Source #

Yes, it's yet another Val variant. This one is even more mini than REnv.Val. TODO NOTE [val-and-minival]

Constructors

VNum !(ScoreT.Typed Signal.Y) 
VStr !Str 

Instances

Instances details
String.IsString MiniVal Source # 
Instance details

Defined in Derive.Expr

Show MiniVal Source # 
Instance details

Defined in Derive.Expr

Eq MiniVal Source # 
Instance details

Defined in Derive.Expr

Methods

(==) :: MiniVal -> MiniVal -> Bool #

(/=) :: MiniVal -> MiniVal -> Bool #

Ord MiniVal Source # 
Instance details

Defined in Derive.Expr

ShowVal MiniVal Source # 
Instance details

Defined in Derive.Expr

Pretty MiniVal Source # 
Instance details

Defined in Derive.Expr

Serialize.Serialize MiniVal Source # 
Instance details

Defined in Derive.Expr

ShowVal (Call MiniVal) Source # 
Instance details

Defined in Derive.Expr

ShowVal (Expr MiniVal) Source # 
Instance details

Defined in Derive.Expr

ShowVal (Term MiniVal) Source # 
Instance details

Defined in Derive.Expr

Pretty (Call MiniVal) Source # 
Instance details

Defined in Derive.Expr

Pretty (Term MiniVal) Source # 
Instance details

Defined in Derive.Expr

class ToVal a where Source #

Methods

to_val :: a -> MiniVal Source #

Instances

Instances details
ToVal Text Source # 
Instance details

Defined in Derive.Expr

Methods

to_val :: Text -> MiniVal Source #

ToVal Double Source # 
Instance details

Defined in Derive.Expr

ToVal Int Source # 
Instance details

Defined in Derive.Expr

Methods

to_val :: Int -> MiniVal Source #