Karya, built on Mon Jul 24 11:39:07 PDT 2017 (patch 33511aca01257b76b88de7c7a2763b7a965c084e)

Safe HaskellNone

Derive.Expr

Contents

Description

The Str and Symbol types, and ToExpr class, in a module with few dependencies so modules can make exprs without incurring a dependency on Derive.BaseTypes, and more importantly, Val, which drags in tons of stuff.

Synopsis

Documentation

type Expr val = NonEmpty.NonEmpty (Call val) Source #

The only operator is |, so a list suffices for an AST.

This is parameterized by the val unparsed exprs are Expr Text while parsed

data Call val Source #

Constructors

Call Symbol [Term val] 

Instances

Functor Call # 

Methods

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

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

Serialize.Serialize Call # 
ToVal Expr # 

Methods

to_val :: Expr -> Val Source #

Eq val => Eq (Call val) # 

Methods

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

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

Read val => Read (Call val) # 

Methods

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

readList :: ReadS [Call val] #

readPrec :: ReadPrec (Call val) #

readListPrec :: ReadPrec [Call val] #

Show val => Show (Call val) # 

Methods

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

show :: Call val -> String.String #

showList :: [Call val] -> ShowS #

String.IsString (Call val) # 

Methods

fromString :: String.String -> Call val #

String.IsString (Expr val) # 

Methods

fromString :: String.String -> Expr val #

ShowVal.ShowVal val => Pretty (Call val) # 

Methods

pretty :: Call val -> Text Source #

format :: Call val -> Doc Source #

formatList :: [Call val] -> Doc Source #

ShowVal.ShowVal val => ShowVal.ShowVal (Call val) # 

Methods

show_val :: Call val -> Text Source #

ShowVal.ShowVal val => ShowVal.ShowVal (Expr val) # 

Methods

show_val :: Expr val -> Text Source #

data Term val Source #

Constructors

ValCall (Call val) 
Literal val 

Instances

Functor Term # 

Methods

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

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

Serialize.Serialize Term # 
Eq val => Eq (Term val) # 

Methods

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

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

Read val => Read (Term val) # 

Methods

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

readList :: ReadS [Term val] #

readPrec :: ReadPrec (Term val) #

readListPrec :: ReadPrec [Term val] #

Show val => Show (Term val) # 

Methods

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

show :: Term val -> String.String #

showList :: [Term val] -> ShowS #

ShowVal.ShowVal val => Pretty (Term val) # 

Methods

pretty :: Term val -> Text Source #

format :: Term val -> Doc Source #

formatList :: [Term val] -> Doc Source #

ShowVal.ShowVal val => ShowVal.ShowVal (Term val) # 

Methods

show_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 

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 Text 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.

Minimal complete definition

to_expr

Methods

to_expr :: a -> Expr Text Source #

Instances

ToExpr Pattern # 
ToExpr Stroke #

TODO should I make these consistent with Strokes?

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.

ToExpr Stroke # 
ToExpr Stroke # 
ToExpr (Stroke Stroke) # 
ToExpr (Stroke Stroke) # 
ToExpr (Stroke Stroke) # 
ToExpr (Stroke Stroke) # 

Str

newtype Str Source #

Constructors

Str Text