module Main where import System import Text ParserCombinators Parsec c

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module Main where
import System
import Text.ParserCombinators.Parsec
close "[" = "]"
close "(" = ")"
close "{" = "}"
openParens = foldl1 (<|>) $ map string ["[", "(", "{"]
closeParens p = string (close p)
emptySequence = return ()
nonEmptySequence = do
p <- openParens
parentheses
closeParens p
parentheses
parentheses = nonEmptySequence <|> emptySequence
main = do
args <- getArgs
putStrLn (check (args !! 0)) where
check input = case parse parentheses "stdin" input of
Left err -> "False: " ++ show err
Right _ -> "True"