module FRP.Rhine.TimeDomain where
import Data.Time.Clock (UTCTime, diffUTCTime)
import Data.VectorSpace.Specific ()
class TimeDomain td where
type Diff td
diffTime :: td -> td -> Diff td
instance TimeDomain UTCTime where
type Diff UTCTime = Double
diffTime t1 t2 = realToFrac $ diffUTCTime t1 t2
instance TimeDomain Double where
type Diff Double = Double
diffTime = ()
instance TimeDomain Float where
type Diff Float = Float
diffTime = ()
instance TimeDomain Integer where
type Diff Integer = Integer
diffTime = ()
instance TimeDomain () where
type Diff () = ()
diffTime _ _ = ()
newtype NumTimeDomain a = NumTimeDomain { fromNumTimeDomain :: a }
deriving Num
instance Num a => TimeDomain (NumTimeDomain a) where
type Diff (NumTimeDomain a) = NumTimeDomain a
diffTime = ()