summaryrefslogtreecommitdiff
path: root/testsuite/tests/programs/jq_readsPrec/Main.hs
blob: 360a411ef04adf4f81bd8b6db4653748d54c2575 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Main where

data Vertex = V Int deriving (Read, Show)

main = do
    userInput <- getContents
    (parseVertex.lines) userInput report

report::Vertex -> IO ()
report int = putStr (show int)

parseVertex::[String] -> (Vertex -> IO ()) -> IO ()
parseVertex inputLines cont
 = case inputLines of
      (l1:rest) -> case (reads l1) of
                     [(x,"")] -> cont x
                     other    -> putStr
                                      ((showString "Error - retype the edges\n".                                      shows other) "")
      _         -> putStr "No Vertex"