{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Network.Mux.DeltaQ.TraceTypes
  ( SISec (..)
  , SISec2 (..)
  , squareSISec
  ) where

-- Map time intervals to real numbers, for the arithmetic.
newtype SISec  = S  Float -- this is all the precision we need,
  deriving (SISec -> SISec -> Bool
(SISec -> SISec -> Bool) -> (SISec -> SISec -> Bool) -> Eq SISec
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SISec -> SISec -> Bool
$c/= :: SISec -> SISec -> Bool
== :: SISec -> SISec -> Bool
$c== :: SISec -> SISec -> Bool
Eq, Eq SISec
Eq SISec
-> (SISec -> SISec -> Ordering)
-> (SISec -> SISec -> Bool)
-> (SISec -> SISec -> Bool)
-> (SISec -> SISec -> Bool)
-> (SISec -> SISec -> Bool)
-> (SISec -> SISec -> SISec)
-> (SISec -> SISec -> SISec)
-> Ord SISec
SISec -> SISec -> Bool
SISec -> SISec -> Ordering
SISec -> SISec -> SISec
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SISec -> SISec -> SISec
$cmin :: SISec -> SISec -> SISec
max :: SISec -> SISec -> SISec
$cmax :: SISec -> SISec -> SISec
>= :: SISec -> SISec -> Bool
$c>= :: SISec -> SISec -> Bool
> :: SISec -> SISec -> Bool
$c> :: SISec -> SISec -> Bool
<= :: SISec -> SISec -> Bool
$c<= :: SISec -> SISec -> Bool
< :: SISec -> SISec -> Bool
$c< :: SISec -> SISec -> Bool
compare :: SISec -> SISec -> Ordering
$ccompare :: SISec -> SISec -> Ordering
$cp1Ord :: Eq SISec
Ord, Integer -> SISec
SISec -> SISec
SISec -> SISec -> SISec
(SISec -> SISec -> SISec)
-> (SISec -> SISec -> SISec)
-> (SISec -> SISec -> SISec)
-> (SISec -> SISec)
-> (SISec -> SISec)
-> (SISec -> SISec)
-> (Integer -> SISec)
-> Num SISec
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> SISec
$cfromInteger :: Integer -> SISec
signum :: SISec -> SISec
$csignum :: SISec -> SISec
abs :: SISec -> SISec
$cabs :: SISec -> SISec
negate :: SISec -> SISec
$cnegate :: SISec -> SISec
* :: SISec -> SISec -> SISec
$c* :: SISec -> SISec -> SISec
- :: SISec -> SISec -> SISec
$c- :: SISec -> SISec -> SISec
+ :: SISec -> SISec -> SISec
$c+ :: SISec -> SISec -> SISec
Num)
newtype SISec2 = S2 Float -- are there performance reasons to use Double?
  deriving (SISec2 -> SISec2 -> Bool
(SISec2 -> SISec2 -> Bool)
-> (SISec2 -> SISec2 -> Bool) -> Eq SISec2
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SISec2 -> SISec2 -> Bool
$c/= :: SISec2 -> SISec2 -> Bool
== :: SISec2 -> SISec2 -> Bool
$c== :: SISec2 -> SISec2 -> Bool
Eq, Eq SISec2
Eq SISec2
-> (SISec2 -> SISec2 -> Ordering)
-> (SISec2 -> SISec2 -> Bool)
-> (SISec2 -> SISec2 -> Bool)
-> (SISec2 -> SISec2 -> Bool)
-> (SISec2 -> SISec2 -> Bool)
-> (SISec2 -> SISec2 -> SISec2)
-> (SISec2 -> SISec2 -> SISec2)
-> Ord SISec2
SISec2 -> SISec2 -> Bool
SISec2 -> SISec2 -> Ordering
SISec2 -> SISec2 -> SISec2
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SISec2 -> SISec2 -> SISec2
$cmin :: SISec2 -> SISec2 -> SISec2
max :: SISec2 -> SISec2 -> SISec2
$cmax :: SISec2 -> SISec2 -> SISec2
>= :: SISec2 -> SISec2 -> Bool
$c>= :: SISec2 -> SISec2 -> Bool
> :: SISec2 -> SISec2 -> Bool
$c> :: SISec2 -> SISec2 -> Bool
<= :: SISec2 -> SISec2 -> Bool
$c<= :: SISec2 -> SISec2 -> Bool
< :: SISec2 -> SISec2 -> Bool
$c< :: SISec2 -> SISec2 -> Bool
compare :: SISec2 -> SISec2 -> Ordering
$ccompare :: SISec2 -> SISec2 -> Ordering
$cp1Ord :: Eq SISec2
Ord, Integer -> SISec2
SISec2 -> SISec2
SISec2 -> SISec2 -> SISec2
(SISec2 -> SISec2 -> SISec2)
-> (SISec2 -> SISec2 -> SISec2)
-> (SISec2 -> SISec2 -> SISec2)
-> (SISec2 -> SISec2)
-> (SISec2 -> SISec2)
-> (SISec2 -> SISec2)
-> (Integer -> SISec2)
-> Num SISec2
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> SISec2
$cfromInteger :: Integer -> SISec2
signum :: SISec2 -> SISec2
$csignum :: SISec2 -> SISec2
abs :: SISec2 -> SISec2
$cabs :: SISec2 -> SISec2
negate :: SISec2 -> SISec2
$cnegate :: SISec2 -> SISec2
* :: SISec2 -> SISec2 -> SISec2
$c* :: SISec2 -> SISec2 -> SISec2
- :: SISec2 -> SISec2 -> SISec2
$c- :: SISec2 -> SISec2 -> SISec2
+ :: SISec2 -> SISec2 -> SISec2
$c+ :: SISec2 -> SISec2 -> SISec2
Num)

squareSISec :: SISec -> SISec2
squareSISec :: SISec -> SISec2
squareSISec (S Float
x) = Float -> SISec2
S2 (Float -> SISec2) -> Float -> SISec2
forall a b. (a -> b) -> a -> b
$ Float
x Float -> Float -> Float
forall a. Num a => a -> a -> a
* Float
x