module Temporal.Class(
	DurOf, Duration(..), Melody(..), Harmony(..), Compose(..), 
	loopBy, melMap, harMap, 
	Delay(..), (+|),
	Rest(..), Stretch(..), (*|), Limit(..), 
	Loop(..)
) where
class Duration a where
	dur :: a -> DurOf a
type family DurOf a :: *
class Melody a where
	
	mel :: [a] -> a
	
	(+:+) :: a -> a -> a
	a +:+ b = mel [a, b]
	mel = foldl1 (+:+)
class Harmony a where
	
	har :: [a] -> a
	
	(=:=) :: a -> a -> a
	a =:= b = har [a, b]
	har = foldl1 (=:=)
class (Melody a, Harmony a) => Compose a where
loopBy :: Melody a => Int -> a -> a
loopBy n = mel . replicate n
class Delay a where
	
	del :: DurOf a -> a -> a
class Stretch a where
	
	str :: DurOf a -> a -> a
(+|) :: Delay a => DurOf a -> a -> a
(+|) = del
(*|) :: Stretch a => DurOf a -> a -> a
(*|) = str
class Rest a where
	rest :: DurOf a -> a
class Limit a where
	
	lim :: DurOf a -> a -> a
class Loop a where
	
	loop :: a -> a
melMap :: (Melody b) => (a -> b) -> [a] -> b
melMap f xs = mel $ fmap f xs
harMap :: (Harmony b) => (a -> b) -> [a] -> b
harMap f xs = har $ fmap f xs