Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Sound/Tidal/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ a |- b = (-) <$> a <* b
( -|) :: Num a => Pattern a -> Pattern a -> Pattern a
a -| b = (-) <$> a *> b

(|%|) :: (Applicative a, Real b) => a b -> a b -> a b
a |%| b = mod' <$> a <*> b
(|% ) :: Real a => Pattern a -> Pattern a -> Pattern a
a |% b = mod' <$> a <* b
( %|) :: Real a => Pattern a -> Pattern a -> Pattern a
a %| b = mod' <$> a *> b
(|%|) :: (Applicative a, Moddable b) => a b -> a b -> a b
a |%| b = gmod <$> a <*> b
(|% ) :: Moddable a => Pattern a -> Pattern a -> Pattern a
a |% b = gmod <$> a <* b
( %|) :: Moddable a => Pattern a -> Pattern a -> Pattern a
a %| b = gmod <$> a *> b

(|**|) :: (Applicative a, Floating b) => a b -> a b -> a b
a |**| b = (**) <$> a <*> b
Expand Down
15 changes: 15 additions & 0 deletions src/Sound/Tidal/Pattern.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import Data.List (delete, findIndex, sort)
import Data.Word (Word8)
import Data.Data (Data) -- toConstr
import Data.Typeable (Typeable)
import Data.Fixed (mod')

import Sound.Tidal.Time

Expand Down Expand Up @@ -297,6 +298,20 @@ instance Fractional ValueMap where
recip = fmap (applyFIS recip id id)
fromRational r = Map.singleton "speed" $ VF (fromRational r)

class Moddable a where
gmod :: a -> a -> a

instance Moddable Double where
gmod = mod'
instance Moddable Rational where
gmod = mod'
instance Moddable Note where
gmod (Note a) (Note b) = Note (mod' a b)
instance Moddable Int where
gmod = mod
instance Moddable ValueMap where
gmod = Map.unionWith (fNum2 mod mod')

instance Floating ValueMap
where pi = noOv "pi"
exp _ = noOv "exp"
Expand Down
2 changes: 1 addition & 1 deletion tidal-parse/src/Sound/Tidal/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ numMergeOperator =
$(fromHaskell "*") <|>
$(fromHaskell "-")

realMergeOperator :: Real a => H (Pattern a -> Pattern a -> Pattern a)
realMergeOperator :: T.Moddable a => H (Pattern a -> Pattern a -> Pattern a)
realMergeOperator =
$(fromTidal "|%|") <|>
$(fromTidal "|%") <|>
Expand Down