1 
    2 module Main where
    3 
    4 import Mandel
    5 import PortablePixmap
    6 import IO --1.3
    7 
    8 main =  getContents >>=                        \ userInput        ->
    9         readNum "Enter min x  = " (lines userInput) $   \ minx input       ->
   10         readNum "Enter min y  = " input $           \ miny input     ->
   11         readNum "Enter max x  = " input $           \ maxx input     ->
   12         readNum "Enter max y  = " input $           \ maxy input     ->
   13         readNum "Screen width = " input $           \ screenX input  ->
   14         readNum "Screen height= " input $           \ screenY input  ->
   15         readNum "Screen depth = " input $           \ limit _   ->
   16         putStr (show (mandelset minx miny maxx maxy screenX screenY limit))
   17 
   18 readNum::(Num a, Read a) => String -> [String] -> (a->[String]->IO ()) -> IO ()
   19 readNum prompt inputLines succ
   20    = hPutStr stderr prompt >>
   21      case inputLines of
   22        (x:xs) -> case (reads x) of
   23                    [(y,"")] -> succ y xs
   24                    _      -> hPutStr stderr "Error - retype the number\n" >>
   25                                readNum prompt xs succ
   26        _        -> hPutStr stderr "Early EOF"
   27 
   28 {-
   29 Enter min x  = -1.5
   30 Enter min y  = -1.0
   31 Enter max x  = 0.5
   32 Enter max y  = 1.0
   33 -}
   34 
   35 
   36