module Data.MediaBus.Basics.SourceId
( SourceId(..)
, sourceIdValue
, type SrcId32
, type SrcId64
, HasSourceId(..)
, EachSourceId(..)
) where
import Control.DeepSeq
import Control.Lens
import Data.Default
import Data.Word
import GHC.Generics (Generic)
import Test.QuickCheck
newtype SourceId i = MkSourceId
{ _sourceIdValue :: i
} deriving (Eq, Arbitrary, Default, Ord, Generic)
sourceIdValue :: Iso (SourceId a) (SourceId b) a b
sourceIdValue = iso _sourceIdValue MkSourceId
type SrcId32 = SourceId Word32
type SrcId64 = SourceId Word64
instance (NFData i) =>
NFData (SourceId i)
instance Show i =>
Show (SourceId i) where
showsPrec d (MkSourceId x) =
showParen (d > 10) $ showString "source-id: " . showsPrec 11 x
class HasSourceId s t where
type SourceIdFrom s
type SourceIdTo t
sourceId :: Lens s t (SourceIdFrom s) (SourceIdTo t)
class EachSourceId s t where
type SourceIdsFrom s
type SourceIdsTo t
eachSourceId :: Traversal s t (SourceIdsFrom s) (SourceIdsTo t)