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

Safe HaskellNone

Ui.Id

Contents

Synopsis

Documentation

data Id Source #

IDs come in two parts, a namespace and a name.

This is so so that you can merge two scores together and not have their IDs clash. Since block calls within a score will generally leave the namespace implicit, the merged score should still be playable.

Instances

Eq Id # 

Methods

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

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

Ord Id # 

Methods

compare :: Id -> Id -> Ordering #

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

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

(>) :: Id -> Id -> Bool #

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

max :: Id -> Id -> Id #

min :: Id -> Id -> Id #

Read.Read Id # 
Show Id # 

Methods

showsPrec :: Int -> Id -> ShowS #

show :: Id -> String #

showList :: [Id] -> ShowS #

DeepSeq.NFData Id # 

Methods

rnf :: Id -> () #

CRC32.CRC32 Id # 

Methods

crc32 :: Id -> Word32 #

crc32Update :: Word32 -> Id -> Word32 #

Pretty Id # 
Serialize.Serialize Id # 
Ident Id # 

access

modify_name :: (Text -> Text) -> Id -> Id Source #

read / show

read_short :: Namespace -> Text -> Id Source #

A smarter constructor that only applies the namespace if the string doesn't already have one.

show_short :: Namespace -> Id -> Text Source #

The inverse of read_short.

validate

valid_symbol :: Text -> Bool Source #

True if this Namespace or Id name follows some strict rules, which are a superset of the rules that make it parseable as an unquoted symbol.

A valid identifier is [a-z][a-z0-9.-]*, as in symbol_description. Hyphens are intended to separate words, and dots intended to separate syntactic elements, whatever those may be. The rules are intentionally restrictive, to force standardization on names, and also to keep some syntactic flexibility in case I want to add special syntax.

I originally used dots for relative calls, but they turn out to be annoying because you can't start a tracklang symbol with one, so now they use a hyphen. Dots are still used for divisions in automatically generated names, for instance, TrackIds are generated as block.t1.

Several kinds of tracklang names use this definition of validity, not just Ids (e.g. instrument or control names). It's easier to remember a single rule for a valid name rather than each syntactic form have its own rules.

symbol_description :: Text Source #

Describe a valid identifier for docs and error messages.

is_id_char :: Char -> Bool Source #

This defines the set of valid characters allowed in an ID.

Ident

class Ident a where Source #

BlockIds, RulerIds, etc. are just wrappers around Ids. Giving them a consistent display format lets me copy and paste them on the repl socket, which puts the constructors in scope.

Minimal complete definition

unpack_id, constructor_name, make

show_ident :: forall a. Ident a => a -> String Source #

ident_text :: Ident a => a -> Text Source #

SomethingId -> "ns/name"

ident_name :: Ident a => a -> Text Source #

SomethingId -> "name"

constants

instances

newtype BlockId Source #

Reference to a Block. Use this to look up Blocks in the State.

The convention is that BlockId should name a block which is expected to exist, and the only way to create a BlockId is via create_block. The name of a block which is to be created is simply Id.

However, since the constructor is exported, this isn't rigorously enforced.

Unlike other Ids, block names have no restrictions, except no spaces. This is because they become note calls, and it's convenient to have arbitrary names for the same reason it's convenient to allow arbitrary characters in call names.

Constructors

BlockId Id