[project @ 1999-06-29 12:00:42 by simonmar]
[ghc-hetmet.git] / ghc / tests / programs / jq_readsPrec / Main.hs
1 module Main where
2
3 data Vertex = V Int deriving (Read, Show)
4
5 main = do
6     userInput <- getContents
7     (parseVertex.lines) userInput report
8
9 report::Vertex -> IO ()
10 report int = putStr (show int)
11
12 parseVertex::[String] -> (Vertex -> IO ()) -> IO ()
13 parseVertex inputLines cont
14  = case inputLines of
15       (l1:rest) -> case (reads l1) of
16                      [(x,"")] -> cont x
17                      other    -> putStr
18                                       ((showString "Error - retype the edges\n".                                      shows other) "")
19       _         -> putStr "No Vertex"
20