{-# LANGUAGE TypeFamilies #-}
module Simulation.Aivika.Trans.Internal.Types
(Specs(..),
Method(..),
Run(..),
Point(..),
Parameter(..),
Simulation(..),
Dynamics(..),
Event(..),
EventProcessing(..),
EventQueueing(..),
invokeParameter,
invokeSimulation,
invokeDynamics,
invokeEvent) where
import Simulation.Aivika.Trans.Generator
data Specs m = Specs { Specs m -> Double
spcStartTime :: Double,
Specs m -> Double
spcStopTime :: Double,
Specs m -> Double
spcDT :: Double,
Specs m -> Method
spcMethod :: Method,
Specs m -> GeneratorType m
spcGeneratorType :: GeneratorType m
}
data Method = Euler
| RungeKutta2
| RungeKutta4
| RungeKutta4b
deriving (Method -> Method -> Bool
(Method -> Method -> Bool)
-> (Method -> Method -> Bool) -> Eq Method
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Method -> Method -> Bool
$c/= :: Method -> Method -> Bool
== :: Method -> Method -> Bool
$c== :: Method -> Method -> Bool
Eq, Eq Method
Eq Method
-> (Method -> Method -> Ordering)
-> (Method -> Method -> Bool)
-> (Method -> Method -> Bool)
-> (Method -> Method -> Bool)
-> (Method -> Method -> Bool)
-> (Method -> Method -> Method)
-> (Method -> Method -> Method)
-> Ord Method
Method -> Method -> Bool
Method -> Method -> Ordering
Method -> Method -> Method
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 :: Method -> Method -> Method
$cmin :: Method -> Method -> Method
max :: Method -> Method -> Method
$cmax :: Method -> Method -> Method
>= :: Method -> Method -> Bool
$c>= :: Method -> Method -> Bool
> :: Method -> Method -> Bool
$c> :: Method -> Method -> Bool
<= :: Method -> Method -> Bool
$c<= :: Method -> Method -> Bool
< :: Method -> Method -> Bool
$c< :: Method -> Method -> Bool
compare :: Method -> Method -> Ordering
$ccompare :: Method -> Method -> Ordering
$cp1Ord :: Eq Method
Ord, Int -> Method -> ShowS
[Method] -> ShowS
Method -> String
(Int -> Method -> ShowS)
-> (Method -> String) -> ([Method] -> ShowS) -> Show Method
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Method] -> ShowS
$cshowList :: [Method] -> ShowS
show :: Method -> String
$cshow :: Method -> String
showsPrec :: Int -> Method -> ShowS
$cshowsPrec :: Int -> Method -> ShowS
Show)
data Run m = Run { Run m -> Specs m
runSpecs :: Specs m,
Run m -> Int
runIndex :: Int,
Run m -> Int
runCount :: Int,
Run m -> EventQueue m
runEventQueue :: EventQueue m,
Run m -> Generator m
runGenerator :: Generator m
}
data Point m = Point { Point m -> Specs m
pointSpecs :: Specs m,
Point m -> Run m
pointRun :: Run m,
Point m -> Double
pointTime :: Double,
Point m -> Int
pointIteration :: Int,
Point m -> Int
pointPhase :: Int
}
newtype Parameter m a = Parameter (Run m -> m a)
newtype Simulation m a = Simulation (Run m -> m a)
newtype Dynamics m a = Dynamics (Point m -> m a)
newtype Event m a = Event (Point m -> m a)
invokeParameter :: Run m -> Parameter m a -> m a
{-# INLINE invokeParameter #-}
invokeParameter :: Run m -> Parameter m a -> m a
invokeParameter Run m
r (Parameter Run m -> m a
m) = Run m -> m a
m Run m
r
invokeSimulation :: Run m -> Simulation m a -> m a
{-# INLINE invokeSimulation #-}
invokeSimulation :: Run m -> Simulation m a -> m a
invokeSimulation Run m
r (Simulation Run m -> m a
m) = Run m -> m a
m Run m
r
invokeDynamics :: Point m -> Dynamics m a -> m a
{-# INLINE invokeDynamics #-}
invokeDynamics :: Point m -> Dynamics m a -> m a
invokeDynamics Point m
p (Dynamics Point m -> m a
m) = Point m -> m a
m Point m
p
invokeEvent :: Point m -> Event m a -> m a
{-# INLINE invokeEvent #-}
invokeEvent :: Point m -> Event m a -> m a
invokeEvent Point m
p (Event Point m -> m a
m) = Point m -> m a
m Point m
p
data EventProcessing = CurrentEvents
| EarlierEvents
| CurrentEventsOrFromPast
| EarlierEventsOrFromPast
deriving (EventProcessing -> EventProcessing -> Bool
(EventProcessing -> EventProcessing -> Bool)
-> (EventProcessing -> EventProcessing -> Bool)
-> Eq EventProcessing
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventProcessing -> EventProcessing -> Bool
$c/= :: EventProcessing -> EventProcessing -> Bool
== :: EventProcessing -> EventProcessing -> Bool
$c== :: EventProcessing -> EventProcessing -> Bool
Eq, Eq EventProcessing
Eq EventProcessing
-> (EventProcessing -> EventProcessing -> Ordering)
-> (EventProcessing -> EventProcessing -> Bool)
-> (EventProcessing -> EventProcessing -> Bool)
-> (EventProcessing -> EventProcessing -> Bool)
-> (EventProcessing -> EventProcessing -> Bool)
-> (EventProcessing -> EventProcessing -> EventProcessing)
-> (EventProcessing -> EventProcessing -> EventProcessing)
-> Ord EventProcessing
EventProcessing -> EventProcessing -> Bool
EventProcessing -> EventProcessing -> Ordering
EventProcessing -> EventProcessing -> EventProcessing
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 :: EventProcessing -> EventProcessing -> EventProcessing
$cmin :: EventProcessing -> EventProcessing -> EventProcessing
max :: EventProcessing -> EventProcessing -> EventProcessing
$cmax :: EventProcessing -> EventProcessing -> EventProcessing
>= :: EventProcessing -> EventProcessing -> Bool
$c>= :: EventProcessing -> EventProcessing -> Bool
> :: EventProcessing -> EventProcessing -> Bool
$c> :: EventProcessing -> EventProcessing -> Bool
<= :: EventProcessing -> EventProcessing -> Bool
$c<= :: EventProcessing -> EventProcessing -> Bool
< :: EventProcessing -> EventProcessing -> Bool
$c< :: EventProcessing -> EventProcessing -> Bool
compare :: EventProcessing -> EventProcessing -> Ordering
$ccompare :: EventProcessing -> EventProcessing -> Ordering
$cp1Ord :: Eq EventProcessing
Ord, Int -> EventProcessing -> ShowS
[EventProcessing] -> ShowS
EventProcessing -> String
(Int -> EventProcessing -> ShowS)
-> (EventProcessing -> String)
-> ([EventProcessing] -> ShowS)
-> Show EventProcessing
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventProcessing] -> ShowS
$cshowList :: [EventProcessing] -> ShowS
show :: EventProcessing -> String
$cshow :: EventProcessing -> String
showsPrec :: Int -> EventProcessing -> ShowS
$cshowsPrec :: Int -> EventProcessing -> ShowS
Show)
class EventQueueing m where
data EventQueue m :: *
newEventQueue :: Specs m -> m (EventQueue m)
enqueueEvent :: Double -> Event m () -> Event m ()
runEvent :: Event m a -> Dynamics m a
{-# INLINE runEvent #-}
runEvent = EventProcessing -> Event m a -> Dynamics m a
forall (m :: * -> *) a.
EventQueueing m =>
EventProcessing -> Event m a -> Dynamics m a
runEventWith EventProcessing
CurrentEvents
runEventWith :: EventProcessing -> Event m a -> Dynamics m a
eventQueueCount :: Event m Int