diff --git a/src/Sound/Tidal/Pattern.hs b/src/Sound/Tidal/Pattern.hs index 82552b74..b709dd1a 100644 --- a/src/Sound/Tidal/Pattern.hs +++ b/src/Sound/Tidal/Pattern.hs @@ -4,6 +4,7 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE InstanceSigs #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {- @@ -92,6 +93,8 @@ type ControlPattern = Pattern ValueMap -- * Applicative and friends instance Applicative Pattern where + -- Repeat the given value once per cycle, forever + pure :: a -> Pattern a pure v = Pattern q (Just 1) (Just v) where q (State a _) = @@ -104,6 +107,31 @@ instance Applicative Pattern where v ) $ cycleArcsInArc a + + -- In each of @a <*> b@, @a <* b@ and @a *> b@ + -- (using the definitions from this module, not the Prelude), + -- the time structure of the result + -- depends on the structures of both @a@ and @b@. + -- They all result in @Event@s with identical @part@s and @value@s. + -- However, their @whole@s are different. + -- + -- For instance, @listToPat [(+1), (+2)] <*> "0 10 100"@ + -- gives the following 4-@Event@ cycle: + -- > (0>⅓)|1 + -- > (⅓>½)|11 + -- > (½>⅔)|12 + -- > (⅔>1)|102 + -- If we use @<*@ instead, we get this: + -- > (0>⅓)-½|1 + -- > 0-(⅓>½)|11 + -- > (½>⅔)-1|12 + -- > ½-(⅔>1)|102 + -- And if we use @*>@, we get this: + -- > (0>⅓)|1 + -- > (⅓>½)-⅔|11 + -- > ⅓-(½>⅔)|12 + -- > (⅔>1)|102 + (<*>) :: Pattern (a -> b) -> Pattern a -> Pattern b (<*>) a b = (applyPatToPatBoth a b) {tactus = lcmr <$> tactus a <*> tactus b} -- | Like @<*>@, but the "wholes" come from the left