The question can be viewed from Advent of Code 2015, Day 1
()()(()()()(()()((()((()))((()((((()()((((((
)()(()()()(()()((()((()))((()((((()()((((())
)()((((())(((((((()(((((((((()(((())(()()(()
((()()(()(())(()((((()((()()()((((())(((((((
)(()(((()())(()((((()))())(())(()(()()))))))
Function
Assign each char with a number, ex. `-1` or `1`.
step :: Num t => Char -> t
step '(' = 1
step ')' = -1
step _ = 0floor :: (Functor f, Num b) => f Char -> f b
floor s = step <$> s
Solution
part1 :: [Char] -> Int
part1 s = sum $ floor spart2 :: [Char] -> Int
part2 s = length $ takeWhile (>=0) $ scanl (+) 0 $ floor s
Debug
>>> part1 <$> readFile "01.input"
>>> part2 <$> readFile "01.input"