Haskell Max Slice Sum
maxSliceSum :: [Int] -> Int
maxSliceSum a = snd (foldl step (minBound, minBound) a)
where
step (tmp, best) v =
let tmp' = max (tmp + v) v
in (tmp', max best tmp')
This is a Kadane-style scan: keep the best running sum and the best overall sum while moving once through the array.