From 0a4bb1fc4e2259dff6ac1b9b71037f06f3442aff Mon Sep 17 00:00:00 2001 From: Joel Kaasinen Date: Mon, 21 Jun 2021 17:30:57 +0300 Subject: [PATCH] part2: typos --- part2.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/part2.html b/part2.html index cb1f3a2..008968c 100644 --- a/part2.html +++ b/part2.html @@ -4214,7 +4214,7 @@ TODO explain `some` and `many`

We can ask QuickCheck to run them in GHCi:

*Examples.QuickCheck> quickCheck propRevSmall
 +++ OK, passed 1 test.
-

So far so good. However this isn’t really what QuickCheck was made for. QuickCheck was designer for property-based testing where you can state a property your code should have, and QuickCheck runs your code with randomized inputs, checking the property every time. What would be a simple property that a correct implementation of reverse has? Reversing a list twice should certainly give us back the same list. Let’s write it out:

+

So far so good. However this isn’t really what QuickCheck was made for. QuickCheck was designed for property-based testing where you can state a property your code should have, and QuickCheck runs your code with randomized inputs, checking the property every time. What would be a simple property that a correct implementation of reverse has? Reversing a list twice should certainly give us back the same list. Let’s write it out:

propRevTwice :: [Int] -> Property
 propRevTwice xs = reverse (reverse xs) === xs

Our Property has an argument, which means that QuickCheck will generate random values and run the test. We can use the verboseCheck function to see which values are run. We can also give a parameter to the test ourselves if we wish to check a specific value.

@@ -4431,7 +4431,7 @@ TODO explain `some` and `many`
scaleMoney :: Double -> Money currency -> Money currency
 scaleMoney factor (Money a) = Money (factor * a)
*Examples.Phantom> :t scaleMoney 3 twoEuros
-scaleMoney 3 euro :: Money EUR
+scaleMoney 3 twoEuros :: Money EUR
 *Examples.Phantom> :t scaleMoney 3 dollar
 scaleMoney 3 dollar :: Money USD

Next up: adding two amounts that are in the same currency. We get a nice type error if we try to add values in two different currencies.