Skip to content

Commit

Permalink
yampa: Adjust indentation to two spaces (KSG Haskell 1.3.0 - 4.2). Refs
Browse files Browse the repository at this point in the history
#215.

Suggestion: Each time a new expression or block-like construct is opened, the
indent should increase by two spaces. When the section ends, the indent returns
to the previous indent level. The indent level applies to both Haskell
expressions and comments throughout the block.
  • Loading branch information
ivanperez-keera committed May 15, 2022
1 parent 6e4f2bc commit d5e8544
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions yampa/src/FRP/Yampa/Random.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ noiseR range g0 = streamToSF (randomRs range g0)
streamToSF :: [b] -> SF a b
streamToSF [] = intErr "AFRP" "streamToSF" "Empty list!"
streamToSF (b:bs) = SF {sfTF = tf0}
where
tf0 _ = (stsfAux bs, b)
where
tf0 _ = (stsfAux bs, b)

stsfAux [] = intErr "AFRP" "streamToSF" "Empty list!"
-- Invarying since stsfAux [] is an error.
stsfAux (b:bs) = SF' tf -- True
where
tf _ _ = (stsfAux bs, b)
stsfAux [] = intErr "AFRP" "streamToSF" "Empty list!"
-- Invarying since stsfAux [] is an error.
stsfAux (b:bs) = SF' tf -- True
where
tf _ _ = (stsfAux bs, b)

-- | Stochastic event source with events occurring on average once every t_avg
-- seconds. However, no more than one event results from any one sampling
Expand All @@ -62,20 +62,19 @@ occasionally :: RandomGen g => g -> Time -> b -> SF a (Event b)
occasionally g t_avg x | t_avg > 0 = SF {sfTF = tf0}
| otherwise = usrErr "AFRP" "occasionally"
"Non-positive average interval."
where
-- Generally, if events occur with an average frequency of f, the
-- probability of at least one event occurring in an interval of t
-- is given by (1 - exp (-f*t)). The goal in the following is to
-- decide whether at least one event occurred in the interval of size
-- dt preceding the current sample point. For the first point,
-- we can think of the preceding interval as being 0, implying
-- no probability of an event occurring.
where
-- Generally, if events occur with an average frequency of f, the
-- probability of at least one event occurring in an interval of t is given
-- by (1 - exp (-f*t)). The goal in the following is to decide whether at
-- least one event occurred in the interval of size dt preceding the
-- current sample point. For the first point, we can think of the preceding
-- interval as being 0, implying no probability of an event occurring.

tf0 _ = (occAux (randoms g :: [Time]), NoEvent)

occAux [] = undefined
occAux (r:rs) = SF' tf -- True
where
where
tf dt _ = let p = 1 - exp (-(dt/t_avg)) -- Probability for at least one
-- event.
in (occAux rs, if r < p then Event x else NoEvent)

0 comments on commit d5e8544

Please sign in to comment.