From d1dc336ef18f76304fc8556e89a5732f4793f30e Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 9 Jun 2024 02:35:28 +0000 Subject: [PATCH 01/12] yampa: Document FRP.Yampa.Random.streamToSF. Refs #296. This commit documents an internal function. We include a precondition that may not be apparent from the code. --- yampa/src/FRP/Yampa/Random.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/yampa/src/FRP/Yampa/Random.hs b/yampa/src/FRP/Yampa/Random.hs index 49701586..5a3e3935 100644 --- a/yampa/src/FRP/Yampa/Random.hs +++ b/yampa/src/FRP/Yampa/Random.hs @@ -45,6 +45,8 @@ noise g0 = streamToSF (randoms g0) noiseR :: (RandomGen g, Random b) => (b, b) -> g -> SF a b noiseR range g0 = streamToSF (randomRs range g0) +-- | Turn an infinite list of elements into an SF producing those elements. The +-- SF ignores its input. streamToSF :: [b] -> SF a b streamToSF [] = intErr "Yampa" "streamToSF" "Empty list!" streamToSF (b:bs) = SF {sfTF = tf0} From 414cd6062bc8002b255a32dc61c8f65065789dca Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 9 Jun 2024 02:37:32 +0000 Subject: [PATCH 02/12] yampa: Document changes in CHANGELOG. Refs #296. --- yampa/CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yampa/CHANGELOG b/yampa/CHANGELOG index 34f0101e..f5a84e14 100644 --- a/yampa/CHANGELOG +++ b/yampa/CHANGELOG @@ -1,3 +1,6 @@ +2024-04-09 Ivan Perez + * Document FRP.Yampa.Random.streamToSF (#296). + 2024-04-07 Ivan Perez * Version bump (0.14.8) (#294). From e66b1ebaa532b9cdf9fefafc48be055ec6b1131f Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 9 Jun 2024 02:40:52 +0000 Subject: [PATCH 03/12] yampa: Document FRP.Yampa.Switches.safeZip. Refs #297. This commit documents an internal function. We include a precondition that may not be apparent. --- yampa/src/FRP/Yampa/Switches.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yampa/src/FRP/Yampa/Switches.hs b/yampa/src/FRP/Yampa/Switches.hs index a3f50e04..89ffefc0 100644 --- a/yampa/src/FRP/Yampa/Switches.hs +++ b/yampa/src/FRP/Yampa/Switches.hs @@ -681,6 +681,9 @@ rpSwitchZ = rpSwitch (safeZip "rpSwitchZ") drpSwitchZ :: [SF a b] -> SF ([a], Event ([SF a b] -> [SF a b])) [b] drpSwitchZ = drpSwitch (safeZip "drpSwitchZ") +-- | Zip two lists. +-- +-- PRE: The first list is not shorter than the second. safeZip :: String -> [a] -> [b] -> [(a, b)] safeZip fn l1 l2 = safeZip' l1 l2 where From afde93a7b811b8afe3f914d01bd66ac357bef2af Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 9 Jun 2024 02:42:06 +0000 Subject: [PATCH 04/12] yampa: Document changes in CHANGELOG. Refs #297. --- yampa/CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/yampa/CHANGELOG b/yampa/CHANGELOG index f5a84e14..90506857 100644 --- a/yampa/CHANGELOG +++ b/yampa/CHANGELOG @@ -1,5 +1,6 @@ 2024-04-09 Ivan Perez * Document FRP.Yampa.Random.streamToSF (#296). + * Document FRP.Yampa.Switches.safeZip (#297). 2024-04-07 Ivan Perez * Version bump (0.14.8) (#294). From 7596b970797e02a0ba4e9424bdf3becd82a978d7 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 9 Jun 2024 02:45:09 +0000 Subject: [PATCH 05/12] yampa: Simplify FRP.Yampa.Switches.safeZip. Refs #298. The function FRP.Yampa.Switches.safeZip, or more specifically, safeZip' inside it, captures a list and then applies some head and tail alternative functions to it. This commit reduces the function by pattern matching on the list, already obtaining the head and the tail. We move the error reporting to a third, default case. --- yampa/src/FRP/Yampa/Switches.hs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/yampa/src/FRP/Yampa/Switches.hs b/yampa/src/FRP/Yampa/Switches.hs index 89ffefc0..1b253d63 100644 --- a/yampa/src/FRP/Yampa/Switches.hs +++ b/yampa/src/FRP/Yampa/Switches.hs @@ -685,22 +685,13 @@ drpSwitchZ = drpSwitch (safeZip "drpSwitchZ") -- -- PRE: The first list is not shorter than the second. safeZip :: String -> [a] -> [b] -> [(a, b)] -safeZip fn l1 l2 = safeZip' l1 l2 +safeZip fn = safeZip' where safeZip' :: [a] -> [b] -> [(a, b)] - safeZip' _ [] = [] - safeZip' as (b:bs) = (head' as, b) : safeZip' (tail' as) bs - - head' :: [a] -> a - head' [] = err - head' (a:_) = a - - tail' :: [a] -> [a] - tail' [] = err - tail' (_:as) = as - - err :: a - err = usrErr "FRP.Yampa.Switches" fn "Input list too short." + safeZip' _ [] = [] + safeZip' (a:as) (b:bs) = (a, b) : safeZip' as bs + safeZip' _ _ = + usrErr "FRP.Yampa.Switches" fn "Input list too short." -- Freezes a "running" signal function, i.e., turns it into a continuation in -- the form of a plain signal function. From 6bc555e606eeb633a0fccc8da81cea12f5768223 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 9 Jun 2024 02:48:31 +0000 Subject: [PATCH 06/12] yampa: Document changes in CHANGELOG. Refs #298. --- yampa/CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/yampa/CHANGELOG b/yampa/CHANGELOG index 90506857..ccbec3e1 100644 --- a/yampa/CHANGELOG +++ b/yampa/CHANGELOG @@ -1,6 +1,7 @@ 2024-04-09 Ivan Perez * Document FRP.Yampa.Random.streamToSF (#296). * Document FRP.Yampa.Switches.safeZip (#297). + * Simplify FRP.Yampa.Switches.safeZip (#298). 2024-04-07 Ivan Perez * Version bump (0.14.8) (#294). From 4656dfcc0c646e998fc5bab134a76e7c623c7ade Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 9 Jun 2024 03:05:01 +0000 Subject: [PATCH 07/12] yampa: Fix date in CHANGELOG. Refs #300. The CHANGELOG has a last modification date that points to April, when the last changes were made in June. --- yampa/CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yampa/CHANGELOG b/yampa/CHANGELOG index ccbec3e1..2ab09b5d 100644 --- a/yampa/CHANGELOG +++ b/yampa/CHANGELOG @@ -1,4 +1,4 @@ -2024-04-09 Ivan Perez +2024-06-08 Ivan Perez * Document FRP.Yampa.Random.streamToSF (#296). * Document FRP.Yampa.Switches.safeZip (#297). * Simplify FRP.Yampa.Switches.safeZip (#298). From 95775b4495ba70f1c25d8bcb59555d8694c21f74 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 9 Jun 2024 03:06:38 +0000 Subject: [PATCH 08/12] yampa: Document changes in CHANGELOG. Refs #300. --- yampa/CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/yampa/CHANGELOG b/yampa/CHANGELOG index 2ab09b5d..e82bfb1c 100644 --- a/yampa/CHANGELOG +++ b/yampa/CHANGELOG @@ -2,6 +2,7 @@ * Document FRP.Yampa.Random.streamToSF (#296). * Document FRP.Yampa.Switches.safeZip (#297). * Simplify FRP.Yampa.Switches.safeZip (#298). + * Fix date in CHANGELOG (#300). 2024-04-07 Ivan Perez * Version bump (0.14.8) (#294). From 58cbb4eeaf31fddbb9999f49155ccc4ebed3b68c Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 9 Jun 2024 03:08:02 +0000 Subject: [PATCH 09/12] yampa: Version bump (0.14.9). Refs #299. --- yampa/Yampa.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yampa/Yampa.cabal b/yampa/Yampa.cabal index 2620c945..9d7c0ef6 100644 --- a/yampa/Yampa.cabal +++ b/yampa/Yampa.cabal @@ -30,7 +30,7 @@ cabal-version: >= 1.10 build-type: Simple name: Yampa -version: 0.14.8 +version: 0.14.9 author: Henrik Nilsson, Antony Courtney maintainer: Ivan Perez (ivan.perez@keera.co.uk) homepage: https://github.com/ivanperez-keera/Yampa/ From 519ed557b4073f72180bd6f6b0909cbdf74e0dc8 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 9 Jun 2024 03:08:10 +0000 Subject: [PATCH 10/12] yampa-test: Version bump (0.14.9). Refs #299. --- yampa-test/yampa-test.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yampa-test/yampa-test.cabal b/yampa-test/yampa-test.cabal index 89200301..4a69d2eb 100644 --- a/yampa-test/yampa-test.cabal +++ b/yampa-test/yampa-test.cabal @@ -31,7 +31,7 @@ cabal-version: >= 1.10 build-type: Simple name: yampa-test -version: 0.14.8 +version: 0.14.9 author: Ivan Perez maintainer: ivan.perez@keera.co.uk homepage: http://github.com/ivanperez-keera/Yampa @@ -84,7 +84,7 @@ library base >= 4 && < 5 , normaldistribution >= 1.1.0.1 && < 1.2 , QuickCheck >= 2.12 && < 2.15 - , Yampa >= 0.14.8 && < 0.15 + , Yampa >= 0.14.9 && < 0.15 default-language: Haskell2010 From 16d1178bfb9fca606090ee67c5142f2e36f4bc79 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 9 Jun 2024 03:08:27 +0000 Subject: [PATCH 11/12] yampa: Document changes in CHANGELOG. Refs #299. --- yampa/CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/yampa/CHANGELOG b/yampa/CHANGELOG index e82bfb1c..60852a0e 100644 --- a/yampa/CHANGELOG +++ b/yampa/CHANGELOG @@ -1,4 +1,5 @@ 2024-06-08 Ivan Perez + * Version bump (0.14.9) (#299). * Document FRP.Yampa.Random.streamToSF (#296). * Document FRP.Yampa.Switches.safeZip (#297). * Simplify FRP.Yampa.Switches.safeZip (#298). From 0e3c2556a4e40d1db6fe3ea3e5ff12ad0e66542c Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 9 Jun 2024 03:08:51 +0000 Subject: [PATCH 12/12] yampa-test: Document changes in CHANGELOG. Refs #299. --- yampa-test/CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yampa-test/CHANGELOG b/yampa-test/CHANGELOG index 8da74a15..800cb239 100644 --- a/yampa-test/CHANGELOG +++ b/yampa-test/CHANGELOG @@ -1,3 +1,6 @@ +2024-06-08 Ivan Perez + * Version bump (0.14.9) (#299). + 2024-04-07 Ivan Perez * Version bump (0.14.8) (#294). * Move definitions to separate line (#292).