Skip to content

Commit

Permalink
recover commens deleted by ormolu, add some instance sigs
Browse files Browse the repository at this point in the history
  • Loading branch information
yaxu committed Jan 23, 2025
1 parent 5dca91c commit 1db1d29
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Sound/Tidal/Pattern.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE InstanceSigs #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

{-
Expand Down Expand Up @@ -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 _) =
Expand All @@ -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
Expand Down

0 comments on commit 1db1d29

Please sign in to comment.