Skip to content

Commit 13c97ef

Browse files
committed
Add notes for Func2 and Func3
1 parent 3cd7e25 commit 13c97ef

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

containers-tests/tests/Utils/Strictness.hs

+11
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ instance (CoArbitrary a, Function a, Arbitrary b) => Arbitrary (Func a b) where
5656
FuncStrict f -> FuncStrict <$> shrink f
5757

5858
-- | Function which may be lazy in its arguments
59+
60+
-- Note: We have two separate cases here because we want to generate functions
61+
-- of type `a -> b -> c` with all possible strictness configurations.
62+
-- `Func a (Func b c)` is not enough for this, since it cannot generate
63+
-- functions that are conditionally lazy in the first argument, for instance:
64+
--
65+
-- leftLazyOr :: Bool -> Bool -> Bool
66+
-- leftLazyOr a b = if b then True else a
67+
5968
data Func2 a b c
6069
= F2A (Func a (Func b c))
6170
| F2B (Func b (Func a c))
@@ -76,6 +85,8 @@ applyFunc2 fun2 x y = case fun2 of
7685
F2B fun -> applyFunc (applyFunc fun y) x
7786

7887
-- | Function which may be lazy in its arguments
88+
89+
-- See Note on Func2.
7990
data Func3 a b c d
8091
= F3A (Func a (Func2 b c d))
8192
| F3B (Func b (Func2 a c d))

0 commit comments

Comments
 (0)