Portability | non-portable (TF,GNTD) |
---|---|
Stability | experimental |
Maintainer | hans@hanshoglund.se |
Safe Haskell | None |
- class Transformable a where
- itransform :: Transformable a => Span -> a -> a
- transformed :: Transformable a => Span -> Iso' a a
- whilst :: (Transformable a, Transformable b) => (a -> b) -> Span -> a -> b
- whilstM :: (Functor f, Transformable a, Transformable b) => (a -> f b) -> Span -> a -> f b
- whilstL :: (Functor f, Transformable a, Transformable b) => LensLike f s t a b -> LensLike f (Span, s) (Span, t) a b
- whilstLT :: (Functor f, Transformable a, Transformable b) => LensLike f s t a b -> LensLike f (Time, s) (Time, t) a b
- whilstLD :: (Functor f, Transformable a, Transformable b) => LensLike f s t a b -> LensLike f (Duration, s) (Duration, t) a b
- whilstStretch :: (Transformable a, Transformable b) => (a -> b) -> Duration -> a -> b
- whilstDelay :: (Transformable a, Transformable b) => (a -> b) -> Time -> a -> b
- spanned :: (Transformable a, Transformable b) => Span -> Lens a b a b
- onSpan :: (Transformable a, Functor f) => LensLike' f a b -> Span -> LensLike' f a b
- conjugateS :: Span -> Span -> Span
- delay :: Transformable a => Duration -> a -> a
- undelay :: Transformable a => Duration -> a -> a
- stretch :: Transformable a => Duration -> a -> a
- compress :: Transformable a => Duration -> a -> a
- delaying :: Duration -> Span
- undelaying :: Duration -> Span
- stretching :: Duration -> Span
- compressing :: Duration -> Span
- delayTime :: Transformable a => Time -> a -> a
The Transformable class
class Transformable a whereSource
Class of values that can be transformed (i.e. scaled and moved) in time.
Law
transform mempty = id transform (s <> t) = transform s . transform t transform (s <> negateV s) = id
Law
onset (delay n a) = n ^+. onset a offset (delay n a) = n ^+. offset a duration (stretch n a) = n * duration a duration (compress n a) = duration a / n
delay n b ! t = b ! (t .-^ n) undelay n b ! t = b ! (t .+^ n)
Lemma
duration a = duration (delay n a)
itransform :: Transformable a => Span -> a -> aSource
Apply the inverse of the given transformation.
itransform
s =transform
(negateV
s)
transformed :: Transformable a => Span -> Iso' a aSource
View the given value in the context of the given transformation.
over
(transformed
s) = (`whilst
` s)
Apply under a transformation
whilst :: (Transformable a, Transformable b) => (a -> b) -> Span -> a -> bSource
whilstM :: (Functor f, Transformable a, Transformable b) => (a -> f b) -> Span -> a -> f bSource
Apply a morphism under transformation (monadic version).
whilstL :: (Functor f, Transformable a, Transformable b) => LensLike f s t a b -> LensLike f (Span, s) (Span, t) a bSource
whilstLT :: (Functor f, Transformable a, Transformable b) => LensLike f s t a b -> LensLike f (Time, s) (Time, t) a bSource
whilstLD :: (Functor f, Transformable a, Transformable b) => LensLike f s t a b -> LensLike f (Duration, s) (Duration, t) a bSource
whilstStretch :: (Transformable a, Transformable b) => (a -> b) -> Duration -> a -> bSource
Apply a function under transformation.
whilstDelay :: (Transformable a, Transformable b) => (a -> b) -> Time -> a -> bSource
Apply a function under transformation.
spanned :: (Transformable a, Transformable b) => Span -> Lens a b a bSource
Transforms a lens of to a Transformable
type to act inside a transformation.
onSpan :: (Transformable a, Functor f) => LensLike' f a b -> Span -> LensLike' f a bSource
Transforms a lens of to a Transformable
type to act inside a transformation.
Designed to be used infix, as in
l `onSpan
` (2 <-> 3)
conjugateS :: Span -> Span -> SpanSource
The conjugate of two spans.
Specific transformations
delay :: Transformable a => Duration -> a -> aSource
Moves a value forward in time.
undelay :: Transformable a => Duration -> a -> aSource
Moves a value backward in time. Equnitvalent to
.
stretch
. negate
stretch :: Transformable a => Duration -> a -> aSource
Stretches (augments) a value by the given factor.
compress :: Transformable a => Duration -> a -> aSource
Compresses (diminishes) a score. Equnitvalent to
.
stretch
. recip
Applied transformations
undelaying :: Duration -> SpanSource
A transformation that moves a value backward in time.
stretching :: Duration -> SpanSource
A transformation that stretches (augments) a value by the given factor.
compressing :: Duration -> SpanSource
A transformation that compresses (diminishes) a value by the given factor.
Utility
delayTime :: Transformable a => Time -> a -> aSource
Delay relative to origin
.
Provided for situations when we really want to use startAt
, but the
type does not have an instance for HasPosition
and we can assume that
the value is starting at time zero.