-- |
-- Module     : Simulation.Aivika.Internal.Arrival
-- Copyright  : Copyright (c) 2009-2017, David Sorokin <david.sorokin@gmail.com>
-- License    : BSD3
-- Maintainer : David Sorokin <david.sorokin@gmail.com>
-- Stability  : experimental
-- Tested with: GHC 8.0.1
--
-- This module defines the types and functions for working with the events
-- that can represent something that arrive from outside the model, or
-- represent other things which computation is delayed and hence is not synchronized.
--
-- Therefore, the additional information is provided about the time and delay of arrival.

module Simulation.Aivika.Internal.Arrival
       (Arrival(..)) where

import Simulation.Aivika.Event

-- | It defines when an event has arrived, usually generated by some random stream.
--
-- Such events should arrive one by one without time lag in the following sense
-- that the model should start awaiting the next event exactly in that time
-- when the previous event has arrived.
--
-- Another use case is a situation when the actual event is not synchronized with
-- the 'Event' computation, being synchronized with the event queue, nevertheless.
-- Then the arrival is used for providing the additional information about the time
-- at which the event had been actually arrived.
data Arrival a =
  Arrival { forall a. Arrival a -> a
arrivalValue :: a,
            -- ^ the data we received with the event
            forall a. Arrival a -> Double
arrivalTime :: Double,
            -- ^ the simulation time at which the event has arrived
            forall a. Arrival a -> Maybe Double
arrivalDelay :: Maybe Double
            -- ^ the delay time which has passed from the time of
            -- arriving the previous event
          } deriving (Arrival a -> Arrival a -> Bool
forall a. Eq a => Arrival a -> Arrival a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Arrival a -> Arrival a -> Bool
$c/= :: forall a. Eq a => Arrival a -> Arrival a -> Bool
== :: Arrival a -> Arrival a -> Bool
$c== :: forall a. Eq a => Arrival a -> Arrival a -> Bool
Eq, Arrival a -> Arrival a -> Bool
Arrival a -> Arrival a -> Ordering
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
forall {a}. Ord a => Eq (Arrival a)
forall a. Ord a => Arrival a -> Arrival a -> Bool
forall a. Ord a => Arrival a -> Arrival a -> Ordering
forall a. Ord a => Arrival a -> Arrival a -> Arrival a
min :: Arrival a -> Arrival a -> Arrival a
$cmin :: forall a. Ord a => Arrival a -> Arrival a -> Arrival a
max :: Arrival a -> Arrival a -> Arrival a
$cmax :: forall a. Ord a => Arrival a -> Arrival a -> Arrival a
>= :: Arrival a -> Arrival a -> Bool
$c>= :: forall a. Ord a => Arrival a -> Arrival a -> Bool
> :: Arrival a -> Arrival a -> Bool
$c> :: forall a. Ord a => Arrival a -> Arrival a -> Bool
<= :: Arrival a -> Arrival a -> Bool
$c<= :: forall a. Ord a => Arrival a -> Arrival a -> Bool
< :: Arrival a -> Arrival a -> Bool
$c< :: forall a. Ord a => Arrival a -> Arrival a -> Bool
compare :: Arrival a -> Arrival a -> Ordering
$ccompare :: forall a. Ord a => Arrival a -> Arrival a -> Ordering
Ord, Int -> Arrival a -> ShowS
forall a. Show a => Int -> Arrival a -> ShowS
forall a. Show a => [Arrival a] -> ShowS
forall a. Show a => Arrival a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Arrival a] -> ShowS
$cshowList :: forall a. Show a => [Arrival a] -> ShowS
show :: Arrival a -> String
$cshow :: forall a. Show a => Arrival a -> String
showsPrec :: Int -> Arrival a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Arrival a -> ShowS
Show)