module Data.MediaBus.Segment
( CanSegment(..)
, Segment(..)
, segmentContent
) where
import Data.MediaBus.Ticks
import Control.Lens
import Data.Default
import Data.Proxy
import Test.QuickCheck
import Control.DeepSeq
import Text.Printf
newtype Segment (duration :: StaticTicks) c = MkSegment { _segmentContent :: c }
deriving (NFData, Default, Arbitrary, Functor, Eq)
instance (HasStaticDuration d, Show c) =>
Show (Segment d c) where
show (MkSegment c) = printf "[| %s |%10s]"
(show c)
(show (getStaticDuration (Proxy :: Proxy d)))
makeLenses ''Segment
instance KnownStaticTicks d =>
HasStaticDuration (Segment d x) where
type SetStaticDuration (Segment d x) pt = Segment pt x
type GetStaticDuration (Segment d x) = d
instance HasStaticDuration d =>
HasDuration (Segment d x) where
getDuration _ = getStaticDuration (Proxy :: Proxy d)
class CanSegment a where
splitAfterDuration :: (HasStaticDuration d)
=> proxy d
-> a
-> Maybe (Segment d a, a)