Safe Haskell | Safe-Inferred |
---|
Synopsis
- data Id
- data Namespace
- id :: Namespace -> Text -> Id
- namespace :: Text -> Namespace
- un_id :: Id -> (Namespace, Text)
- un_namespace :: Namespace -> Text
- id_name :: Id -> Text
- id_namespace :: Id -> Namespace
- set_namespace :: Namespace -> Id -> Id
- set_name :: Text -> Id -> Id
- modify_name :: (Text -> Text) -> Id -> Id
- read_id :: Text -> Id
- show_id :: Id -> Text
- read_short :: Namespace -> Text -> Id
- show_short :: Namespace -> Id -> Text
- valid_symbol :: Text -> Bool
- symbol_description :: Text
- is_id_char :: Char -> Bool
- class Ident a where
- unpack_id :: a -> Id
- constructor_name :: Proxy a -> String
- make :: Id -> Maybe a
- make_unchecked :: Id -> a
- show_ident :: forall a. Ident a => a -> String
- read_ident :: forall a. Ident a => ReadPrec.ReadPrec (Maybe a)
- ident_text :: Ident a => a -> Text
- text_ident :: Ident a => Text -> Maybe a
- ident_name :: Ident a => a -> Text
- ident_namespace :: Ident a => a -> Namespace
- modify :: Ident a => (Id -> Id) -> a -> a
- global :: Text -> Id
- global_namespace :: Namespace
- newtype BlockId = BlockId Id
- newtype ViewId = ViewId Id
- newtype TrackId = TrackId Id
- newtype RulerId = RulerId Id
Documentation
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.
The Namespace should pass valid_symbol
, and is guaranteed to not contain
/s. This is because the git backend uses the namespace for a directory
name.
access
un_namespace :: Namespace -> Text Source #
id_namespace :: Id -> Namespace 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
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.
constructor_name :: Proxy a -> String Source #
make :: Id -> Maybe a Source #
make_unchecked :: Id -> a Source #
show_ident :: forall a. Ident a => a -> String Source #
read_ident :: forall a. Ident a => ReadPrec.ReadPrec (Maybe a) Source #
ident_text :: Ident a => a -> Text Source #
SomethingId -> "ns/name"
ident_name :: Ident a => a -> Text Source #
SomethingId -> "name"
ident_namespace :: Ident a => a -> Namespace Source #
constants
instances
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.
Reference to a View, as per BlockId
.