Skip to content

Commit

Permalink
yampa: Prefer where to let (KSG Haskell 1.3.0 - 5.1). Refs #266.
Browse files Browse the repository at this point in the history
When allowed, prefer where to let clauses (except as needed in do blocks
and arrow blocks).
  • Loading branch information
ivanperez-keera committed Apr 29, 2023
1 parent 1625c4a commit 6ba8d75
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions yampa/src/FRP/Yampa/Conditional.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,26 @@ pause bInit (SF { sfTF = tfP}) (SF {sfTF = tf10}) = SF {sfTF = tf0}
-- recurse.
tf0 a0 = case tfP a0 of
(c, True) -> (pauseInit bInit tf10 c, bInit)
(c, False) -> let (k, b0) = tf10 a0
in (pause' b0 k c, b0)
(c, False) -> (pause' b0 k c, b0)
where
(k, b0) = tf10 a0

-- Similar deal, but with a time delta
pauseInit :: b -> (a -> Transition a b) -> SF' a Bool -> SF' a b
pauseInit bInit' tf10' c = SF' tf0'
where
tf0' dt a =
case (sfTF' c) dt a of
(c', True) -> (pauseInit bInit' tf10' c', bInit')
(c', False) -> let (k, b0) = tf10' a
in (pause' b0 k c', b0)
tf0' dt a = case (sfTF' c) dt a of
(c', True) -> (pauseInit bInit' tf10' c', bInit')
(c', False) -> (pause' b0 k c', b0)
where
(k, b0) = tf10' a

-- Very same deal (almost alpha-renameable)
pause' :: b -> SF' a b -> SF' a Bool -> SF' a b
pause' bInit' tf10' tfP' = SF' tf0'
where
tf0' dt a =
case (sfTF' tfP') dt a of
(tfP'', True) -> (pause' bInit' tf10' tfP'', bInit')
(tfP'', False) -> let (tf10'', b0') = (sfTF' tf10') dt a
in (pause' b0' tf10'' tfP'', b0')
tf0' dt a = case (sfTF' tfP') dt a of
(tfP'', True) -> (pause' bInit' tf10' tfP'', bInit')
(tfP'', False) -> (pause' b0' tf10'' tfP'', b0')
where
(tf10'', b0') = (sfTF' tf10') dt a

0 comments on commit 6ba8d75

Please sign in to comment.