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 0f09b94 commit 6e4f2bc
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions yampa/src/FRP/Yampa/Integration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ import FRP.Yampa.InternalCore (SF(..), SF'(..), DTime)
{-# INLINE integral #-}
integral :: VectorSpace a s => SF a a
integral = SF {sfTF = tf0}
where
tf0 a0 = (integralAux igrl0 a0, igrl0)
where
tf0 a0 = (integralAux igrl0 a0, igrl0)

igrl0 = zeroVector
igrl0 = zeroVector

integralAux igrl a_prev = SF' tf -- True
where
tf dt a = (integralAux igrl' a, igrl')
where
igrl' = igrl ^+^ realToFrac dt *^ a_prev
integralAux igrl a_prev = SF' tf -- True
where
tf dt a = (integralAux igrl' a, igrl')
where
igrl' = igrl ^+^ realToFrac dt *^ a_prev

-- | \"Immediate\" integration (using the function's value at the current time)
imIntegral :: VectorSpace a s => a -> SF a a
Expand All @@ -71,19 +71,19 @@ imIntegral = ((\ _ a' dt v -> v ^+^ realToFrac dt *^ a') `iterFrom`)
-- new output.
iterFrom :: (a -> a -> DTime -> b -> b) -> b -> SF a b
f `iterFrom` b = SF (iterAux b)
where
iterAux b a = (SF' (\ dt a' -> iterAux (f a a' dt b) a'), b)
where
iterAux b a = (SF' (\ dt a' -> iterAux (f a a' dt b) a'), b)

-- | A very crude version of a derivative. It simply divides the
-- value difference by the time difference. Use at your own risk.
derivative :: VectorSpace a s => SF a a
derivative = SF {sfTF = tf0}
where
tf0 a0 = (derivativeAux a0, zeroVector)
where
tf0 a0 = (derivativeAux a0, zeroVector)

derivativeAux a_prev = SF' tf -- True
where
tf dt a = (derivativeAux a, (a ^-^ a_prev) ^/ realToFrac dt)
derivativeAux a_prev = SF' tf -- True
where
tf dt a = (derivativeAux a, (a ^-^ a_prev) ^/ realToFrac dt)

-- | Integrate the first input signal and add the /discrete/ accumulation (sum)
-- of the second, discrete, input signal.
Expand Down

0 comments on commit 6e4f2bc

Please sign in to comment.