arith :: forall a. Arith a => Gen (NodeBuilder a)
arith = sized tree'
  where tree' 0 = return . Const <$> arbitrary
        tree' n = oneof [return . Const <$> arbitrary,
                         mkArithM <$> split 2 <*> arbitrary <*> split 2,
                         mkIfM <$> subBool 3 <*> split 3 <*> split 3
                        ]
          where split m = tree' (n `div` m)
                subBool m = resize (n `div` m) (bool (getType :: a))
arith :: forall a. Arith a => Gen (NodeBuilder a)
arith = sized tree'
  where tree' 0 = return . Const <$> arbitrary
        tree' n = oneof [return . Const <$> arbitrary,
                         mkArithM <$> split 2 <*> arbitrary <*> split 2,
                         mkIfM <$> subBool 3 <*> split 3 <*> split 3
                        ]
          where split m = tree' (n `div` m)
                subBool m = resize (n `div` m) (bool (getType :: a))
arith = sized tree'
  where tree' 0 = return . Const <$> arbitrary
        tree' n = oneof [return . Const <$> arbitrary,
                         mkArithM <$> split 2 <*> arbitrary <*> split 2,
                         mkIfM <$> subBool 3 <*> split 3 <*> split 3
                        ]
          where split m = tree' (n `div` m)
                subBool m = resize (n `div` m) (bool (getType :: a))