squareSum = let square x = x * x in getSum . foldMap (Sum . square)
Btw, you gave "tests" but the tests don't have the supposed results. I know I can hand calculate but still they are not complete test cases.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.