Karya, built on 2020-11-26T21:03:17 (patch 23b5be2d53a9e8e7d6136cda5aae2849abe5cded)
Safe HaskellNone

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 |, so a list suffices for an AST.

This is parameterized by the literal value, so partially parsed exprs are Expr Text while fully parsed ones would be Expr Val.

data Call val Source #

Constructors

Call Symbol [Term val] 

Instances

Instances details
Functor Call # 
Instance details

Defined in Derive.Expr

Methods

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

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

Serialize.Serialize Call # 
Instance details

Defined in Derive.RestrictedEnviron

ToVal Expr # 
Instance details

Defined in Derive.RestrictedEnviron

Methods

to_val :: Expr -> Val Source #

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

Defined in Derive.Expr

Methods

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

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

Read val => Read (Call val) # 
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) # 
Instance details

Defined in Derive.Expr

Methods

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

show :: Call val -> String.String #

showList :: [Call val] -> ShowS #

String.IsString (Call val) # 
Instance details

Defined in Derive.Expr

Methods

fromString :: String.String -> Call val #

String.IsString (Expr val) # 
Instance details

Defined in Derive.Expr

Methods

fromString :: String.String -> Expr val #

Pretty (Call Text) # 
Instance details

Defined in Derive.Expr

Pretty (Call MiniVal) # 
Instance details

Defined in Derive.Expr

Pretty (Call Val) # 
Instance details

Defined in Derive.DeriveT

ShowVal (Call Text) # 
Instance details

Defined in Derive.Expr

Methods

show_val :: Call Text -> Text Source #

ShowVal (Call MiniVal) # 
Instance details

Defined in Derive.Expr

ShowVal (Call Val) # 
Instance details

Defined in Derive.DeriveT

Methods

show_val :: Call Val -> Text Source #

ShowVal (Expr Text) # 
Instance details

Defined in Derive.Expr

Methods

show_val :: Expr Text -> Text Source #

ShowVal (Expr MiniVal) # 
Instance details

Defined in Derive.Expr

ShowVal (Expr Val) # 
Instance details

Defined in Derive.DeriveT

Methods

show_val :: Expr Val -> Text Source #

data Term val Source #

Constructors

ValCall (Call val) 
Literal val 

Instances

Instances details
Functor Term # 
Instance details

Defined in Derive.Expr

Methods

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

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

Serialize.Serialize Term # 
Instance details

Defined in Derive.RestrictedEnviron

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

Defined in Derive.Expr

Methods

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

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

Read val => Read (Term val) # 
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) # 
Instance details

Defined in Derive.Expr

Methods

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

show :: Term val -> String.String #

showList :: [Term val] -> ShowS #

Pretty (Term Text) # 
Instance details

Defined in Derive.Expr

Pretty (Term MiniVal) # 
Instance details

Defined in Derive.Expr

Pretty (Term Val) # 
Instance details

Defined in Derive.DeriveT

ShowVal (Term Text) # 
Instance details

Defined in Derive.Expr

Methods

show_val :: Term Text -> Text Source #

ShowVal (Term MiniVal) # 
Instance details

Defined in Derive.Expr

ShowVal (Term Val) # 
Instance details

Defined in Derive.DeriveT

Methods

show_val :: Term Val -> Text Source #

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
Eq Symbol # 
Instance details

Defined in Derive.Expr

Methods

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

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

Ord Symbol # 
Instance details

Defined in Derive.Expr

Read Symbol # 
Instance details

Defined in Derive.Expr

Show Symbol # 
Instance details

Defined in Derive.Expr

String.IsString Symbol # 
Instance details

Defined in Derive.Expr

Semigroup Symbol # 
Instance details

Defined in Derive.Expr

Monoid Symbol # 
Instance details

Defined in Derive.Expr

DeepSeq.NFData Symbol # 
Instance details

Defined in Derive.Expr

Methods

rnf :: Symbol -> () #

Pretty Symbol # 
Instance details

Defined in Derive.Expr

Serialize.Serialize Symbol # 
Instance details

Defined in Derive.Expr

ShowVal Symbol # 
Instance details

Defined in Derive.Expr

Methods

show_val :: Symbol -> Text Source #

ToVal Symbol # 
Instance details

Defined in Derive.Typecheck

Methods

to_val :: Symbol -> Val Source #

Typecheck Symbol # 
Instance details

Defined in Derive.Typecheck

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 Sollu # 
Instance details

Defined in Solkattu.Instrument.Konnakol

ToExpr Pattern # 
Instance details

Defined in Solkattu.Solkattu

ToExpr Stroke # 
Instance details

Defined in Solkattu.Instrument.Sargam

ToExpr Stroke # 
Instance details

Defined in Solkattu.Instrument.Reyong

ToExpr Stroke #

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 #

TODO should I make these consistent with Strokes?

Instance details

Defined in Solkattu.Instrument.KendangTunggal

ToExpr Stroke #

These have to match with Cmd.Instrument.KendangBali.

Instance details

Defined in Solkattu.Instrument.KendangPasang

ToExpr (Stroke Sollu) # 
Instance details

Defined in Solkattu.Instrument.Konnakol

ToExpr (Stroke Stroke) # 
Instance details

Defined in Solkattu.Instrument.Sargam

ToExpr (Stroke Stroke) # 
Instance details

Defined in Solkattu.Instrument.Reyong

ToExpr (Stroke Stroke) # 
Instance details

Defined in Solkattu.Instrument.Mridangam

ToExpr (Stroke Stroke) # 
Instance details

Defined in Solkattu.Instrument.KendangTunggal

ToExpr (Stroke Stroke) # 
Instance details

Defined in Solkattu.Instrument.KendangPasang

Str

newtype Str Source #

Constructors

Str Text 

Instances

Instances details
Eq Str # 
Instance details

Defined in Derive.Expr

Methods

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

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

Ord Str # 
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 #

Read Str # 
Instance details

Defined in Derive.Expr

Show Str # 
Instance details

Defined in Derive.Expr

Methods

showsPrec :: Int -> Str -> ShowS #

show :: Str -> String.String #

showList :: [Str] -> ShowS #

String.IsString Str # 
Instance details

Defined in Derive.Expr

DeepSeq.NFData Str # 
Instance details

Defined in Derive.Expr

Methods

rnf :: Str -> () #

Pretty Str # 
Instance details

Defined in Derive.Expr

Serialize.Serialize Str # 
Instance details

Defined in Derive.Expr

ShowVal Str # 
Instance details

Defined in Derive.Expr

Methods

show_val :: Str -> Text Source #

ToVal Str # 
Instance details

Defined in Derive.RestrictedEnviron

Methods

to_val :: Str -> Val Source #

ToVal Str # 
Instance details

Defined in Derive.Typecheck

Methods

to_val :: Str -> Val Source #

Typecheck Str # 
Instance details

Defined in Derive.Typecheck

data MiniVal Source #

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

Constructors

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

Instances

Instances details
Eq MiniVal # 
Instance details

Defined in Derive.Expr

Methods

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

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

Ord MiniVal # 
Instance details

Defined in Derive.Expr

Show MiniVal # 
Instance details

Defined in Derive.Expr

String.IsString MiniVal # 
Instance details

Defined in Derive.Expr

Pretty MiniVal # 
Instance details

Defined in Derive.Expr

Serialize.Serialize MiniVal # 
Instance details

Defined in Derive.Expr

ShowVal MiniVal # 
Instance details

Defined in Derive.Expr

Pretty (Term MiniVal) # 
Instance details

Defined in Derive.Expr

Pretty (Call MiniVal) # 
Instance details

Defined in Derive.Expr

ShowVal (Term MiniVal) # 
Instance details

Defined in Derive.Expr

ShowVal (Call MiniVal) # 
Instance details

Defined in Derive.Expr

ShowVal (Expr MiniVal) # 
Instance details

Defined in Derive.Expr