@@ -26,7 +26,6 @@ import Control.Applicative (Applicative (..), (<$>))
2626#endif
2727import Control.Applicative (Alternative (.. ))
2828import Control.Arrow as X
29- import qualified Control.Category as Category
3029import Control.DeepSeq (NFData (.. ))
3130import qualified Control.Monad.Fail as Fail
3231import Control.Monad.Random (MonadRandom )
@@ -47,36 +46,16 @@ import Data.MonadicStreamFunction as X hiding
4746 trace )
4847import Data.MonadicStreamFunction.InternalCore (MSF (MSF , unMSF ))
4948import FRP.BearRiver.Arrow as X
49+ import FRP.BearRiver.Basic as X
50+ import FRP.BearRiver.InternalCore as X
5051
5152-- Internal imports (dunai, instances)
5253import Data.MonadicStreamFunction.Instances.ArrowLoop () -- not needed, just
5354 -- re-exported
54-
55- infixr 0 --> , -:> , >-- , >=-
55+ --
5656
5757-- * Basic definitions
5858
59- -- | Time is used both for time intervals (duration), and time w.r.t. some
60- -- agreed reference point in time.
61- type Time = Double
62-
63- -- | DTime is the time type for lengths of sample intervals. Conceptually,
64- -- DTime = R+ = { x in R | x > 0 }. Don't assume Time and DTime have the same
65- -- representation.
66- type DTime = Double
67-
68- -- | Extensible signal function (signal function with a notion of time, but
69- -- which can be extended with actions).
70- --
71- -- Signal function that transforms a signal carrying values of some type 'a'
72- -- into a signal carrying values of some type 'b'. You can think of it as
73- -- (Signal a -> Signal b). A signal is, conceptually, a function from 'Time' to
74- -- value.
75- type SF m = MSF (ClockInfo m )
76-
77- -- | Information on the progress of time.
78- type ClockInfo m = ReaderT DTime m
79-
8059-- | A single possible event occurrence, that is, a value that may or may not
8160-- occur. Events are used to represent values that are not produced
8261-- continuously, such as mouse clicks (only produced when the mouse is clicked,
@@ -144,22 +123,6 @@ arrEPrim = arr
144123
145124-- ** Basic signal functions
146125
147- -- | Identity: identity = arr id
148- --
149- -- Using 'identity' is preferred over lifting id, since the arrow combinators
150- -- know how to optimise certain networks based on the transformations being
151- -- applied.
152- identity :: Monad m => SF m a a
153- identity = Category. id
154-
155- -- | Identity: constant b = arr (const b)
156- --
157- -- Using 'constant' is preferred over lifting const, since the arrow
158- -- combinators know how to optimise certain networks based on the
159- -- transformations being applied.
160- constant :: Monad m => b -> SF m a b
161- constant = arr . const
162-
163126-- | Outputs the time passed since the signal function instance was started.
164127localTime :: Monad m => SF m a Time
165128localTime = constant 1.0 >>> integral
@@ -168,40 +131,6 @@ localTime = constant 1.0 >>> integral
168131time :: Monad m => SF m a Time
169132time = localTime
170133
171- -- ** Initialization
172-
173- -- | Initialization operator (cf. Lustre/Lucid Synchrone).
174- --
175- -- The output at time zero is the first argument, and from that point on it
176- -- behaves like the signal function passed as second argument.
177- (-->) :: Monad m => b -> SF m a b -> SF m a b
178- b0 --> sf = sf >>> replaceOnce b0
179-
180- -- | Output pre-insert operator.
181- --
182- -- Insert a sample in the output, and from that point on, behave like the given
183- -- sf.
184- (-:>) :: Monad m => b -> SF m a b -> SF m a b
185- b -:> sf = iPost b sf
186-
187- -- | Input initialization operator.
188- --
189- -- The input at time zero is the first argument, and from that point on it
190- -- behaves like the signal function passed as second argument.
191- (>--) :: Monad m => a -> SF m a b -> SF m a b
192- a0 >-- sf = replaceOnce a0 >>> sf
193-
194- -- | Transform initial input value.
195- --
196- -- Applies a transformation 'f' only to the first input value at time zero.
197- (>=-) :: Monad m => (a -> a ) -> SF m a b -> SF m a b
198- f >=- sf = MSF $ \ a -> do
199- (b, sf') <- unMSF sf (f a)
200- return (b, sf')
201-
202- -- | Override initial value of input signal.
203- initially :: Monad m => a -> SF m a a
204- initially = (--> identity)
205134
206135-- * Simple, stateful signal processing
207136
@@ -878,12 +807,3 @@ evalAt sf dt a = runIdentity $ runReaderT (unMSF sf a) dt
878807-- discrete and step based.
879808evalFuture :: SF Identity a b -> a -> DTime -> (b , SF Identity a b )
880809evalFuture sf = flip (evalAt sf)
881-
882- -- * Auxiliary functions
883-
884- -- ** Event handling
885-
886- -- | Replace the value of the input signal at time zero with the given
887- -- argument.
888- replaceOnce :: Monad m => a -> SF m a a
889- replaceOnce a = dSwitch (arr $ const (a, Event () )) (const $ arr id )
0 commit comments