module Temporal.Music.Notation.Seg(
Seg(..), segSize
-- IntSeg(..),
-- module TypeLevel.Nat.Decimal
)
where
--import TypeLevel.Nat.Decimal
-- | 'Seg' means segment, values that 'Enum' and 'Bounded'.
class (Enum a, Bounded a) => Seg a where
segSize :: Seg a => a -> Int
segSize x = 1 + phi maxBound x - phi minBound x
where phi a b = fromEnum $ a `asTypeOf` b
{-
-- | Bounded 'Int'. Type parameter encodes 'maxBound',
-- 'minBound' equals to zero.
newtype Nat n => IntSeg n = IntSeg { runIntSeg :: Int }
deriving (Show, Eq)
instance Nat n => Bounded (IntSeg n) where
minBound = IntSeg 0
maxBound = res
where res = IntSeg $ toInt $ phi res
phi :: IntSeg n -> n
phi = const undefined
instance Nat n => Enum (IntSeg n) where
fromEnum = runIntSeg
toEnum x = res
where res = phi res x
phi t x
| x < a || x > b = error "IntSeg :: out of bounds"
| otherwise = IntSeg x
where a = fromEnum $ minBound `asTypeOf` t
b = fromEnum $ maxBound `asTypeOf` t
instance Nat n => Seg (IntSeg n)
-}