function2
  :: (a -> Gen r -> Gen r)
  -> (b -> Gen r -> Gen r)
  -> Gen r
  -> Gen (a -> b -> r)
function2 p1 p2 = fmap f . function1 p'
  where
    p' (a, b) = p1 a . p2 b
    f g = \a b -> g (a, b)
function2
  :: (a -> Gen r -> Gen r)
  -> (b -> Gen r -> Gen r)
  -> Gen r
  -> Gen (a -> b -> r)
function2 p1 p2 = fmap f . function1 p'
  where
    p' (a, b) = p1 a . p2 b
    f g = \a b -> g (a, b)
function2 p1 p2 = fmap f . function1 p'
  where
    p' (a, b) = p1 a . p2 b
    f g = \a b -> g (a, b)