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

Derive.Stream

Description

A Stream is a collection of LEvent.LEvents which is hopefully sorted in time order.

Synopsis

Documentation

data Stream a Source #

A list seems inefficient, since each call appends to the stream. A block call will then append a bunch of events which need to be copied, and recopied as part of the larger chunk for the next block call up. It's possible the head of the stream will also be copied every time something is appended to it, but I'm not sure about that. It could also be that the number of events is low enough that all the inefficiency doesnt actually matter, but I'm not sure. I need to understand profiling to tell.

TODO one possibility is a MergeList:

data MergeList a = Chunk [a] | Merge (MergeList a) (MergeList a)

This way I don't need to copy large chunks multiple times. Also, if I make sure there is no data dependency between the merge branches, I can evaluate them in parallel.

Each call generates a chunk [Event], and the chunks are then joined with (<>). This means every cons is copied once, but I think this is hard to avoid if I want to merge streams.

TODO the Functor and Traversable can destroy the order, but this isn't checked. Maybe I shouldn't have them?

Currently I don't actually track order, and just trust the callers.

Instances

Instances details
Functor Stream Source # 
Instance details

Defined in Derive.Stream

Methods

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

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

Monoid NoteDeriver Source # 
Instance details

Defined in Derive.Deriver.Monad

Semigroup NoteDeriver Source # 
Instance details

Defined in Derive.Deriver.Monad

Show Builtins Source # 
Instance details

Defined in Derive.Deriver.Monad

Show InstrumentCalls Source # 
Instance details

Defined in Derive.Deriver.Monad

Show Library Source # 
Instance details

Defined in Derive.Library

ShowVal ControlDeriver Source # 
Instance details

Defined in Derive.Deriver.Monad

ShowVal NoteDeriver Source #

This is an invalid instance, because a deriver has no literal syntax. But this lets me put a deriver in a defaulted argument, and get documentation for it.

Instance details

Defined in Derive.Deriver.Monad

ShowVal PitchDeriver Source # 
Instance details

Defined in Derive.Deriver.Monad

Typecheck ControlDeriver Source # 
Instance details

Defined in Derive.Sig

Typecheck NoteDeriver Source # 
Instance details

Defined in Derive.Sig

Typecheck PitchDeriver Source # 
Instance details

Defined in Derive.Sig

Monoid (Stream PSignal) Source # 
Instance details

Defined in Derive.Stream

Monoid (Stream Score.Event) Source # 
Instance details

Defined in Derive.Stream

Monoid (Stream Signal.Control) Source #

Signal.Control streams don't need sorted order.

Instance details

Defined in Derive.Stream

Semigroup (Stream PSignal) Source # 
Instance details

Defined in Derive.Stream

Semigroup (Stream Score.Event) Source # 
Instance details

Defined in Derive.Stream

Semigroup (Stream Signal.Control) Source # 
Instance details

Defined in Derive.Stream

Show a => Show (Stream a) Source # 
Instance details

Defined in Derive.Stream

Methods

showsPrec :: Int -> Stream a -> ShowS #

show :: Stream a -> String #

showList :: [Stream a] -> ShowS #

DeepSeq.NFData a => DeepSeq.NFData (Stream a) Source # 
Instance details

Defined in Derive.Stream

Methods

rnf :: Stream a -> () #

Callable (Transformer Control) Source # 
Instance details

Defined in Derive.Deriver.Monad

Callable (Transformer Note) Source # 
Instance details

Defined in Derive.Deriver.Monad

Callable (Transformer Pitch) Source # 
Instance details

Defined in Derive.Deriver.Monad

ToLibrary (Transformer Control) Source # 
Instance details

Defined in Derive.Library

ToLibrary (Transformer Note) Source # 
Instance details

Defined in Derive.Library

ToLibrary (Transformer Pitch) Source # 
Instance details

Defined in Derive.Library

Pretty.Pretty a => Pretty.Pretty (Stream a) Source # 
Instance details

Defined in Derive.Stream

construct

from_sorted_events :: [a] -> Stream a Source #

Promise that the stream is really sorted.

extract

partition :: Stream a -> ([a], [Log.Msg]) Source #

events_of :: Stream a -> [a] Source #

transform

take_while :: (a -> Bool) -> Stream a -> Stream a Source #

drop_while :: (a -> Bool) -> Stream a -> Stream a Source #

cat_maybes :: Stream (Maybe a) -> Stream a Source #

catMaybes for Stream.

merge_asc_lists :: [Stream Score.Event] -> Stream Score.Event Source #

Merge sorted lists of events. If the lists themselves are also sorted, I can produce output without scanning the entire input list, so this should be more efficient for a large input list than (<>).

This assumes all the streams are sorted. I could check first, but this would destroy the laziness. Instead, let it be out of order, and Convert will complain about it.

levent_key :: LEvent.LEvent Score.Event -> RealTime Source #

This will make logs always merge ahead of score events, but that should be ok.

specific transformations

first :: (a -> Bool) -> (a -> a) -> Stream a -> Stream a Source #

Apply to the first Event that matches the predicate.

first_last :: (a -> Bool) -> (a -> a) -> (a -> a) -> Stream a -> Stream a Source #

Apply to the first and last Event that matches the predicate. If there are fewer than 2 such events, do nothing.

zip

zip :: [a] -> Stream x -> Stream (a, x) Source #

zip_on :: ([a] -> [b]) -> Stream a -> Stream (b, a) Source #

zip3 :: [a] -> [b] -> Stream x -> Stream (a, b, x) Source #

zip3_on :: ([a] -> [b]) -> ([a] -> [c]) -> Stream a -> Stream (b, c, a) Source #

zip4 :: [a] -> [b] -> [c] -> Stream x -> Stream (a, b, c, x) Source #

misc util