new :: Turtle -> String -> String -> IO Turtle
new t xstr ystr = case ( readMaybe xstr :: Maybe Int
                       , readMaybe ystr :: Maybe Int
                       )
                  of
                    (Nothing,Nothing) -> error ("Parse error on line "
                                                ++ show (comln t)
                                                ++ ": bad new size "
                                                ++ "arguments: '" ++ xstr
                                                ++ "' '" ++ ystr ++ "'")
                                         >> exitFailure >> nEW_TURTLE
                    (Nothing,_)       -> error ("Parse error on line "
                                              ++ show (comln t)
                                                ++ ": bad new x size "
                                                ++ "argument: '" ++ xstr ++ "'")
                                         >> exitFailure >> nEW_TURTLE
                    (_,Nothing)       -> error ("Parse error on line "
                                                ++ show (comln t)
                                                ++ ": bad new y argument: '"
                                                ++ ystr ++ "'")
                                         >> exitFailure >> nEW_TURTLE
                    (Just x,Just y)   -> return
                                         $ Turtle { loc   = (0,0)
                                                  , color = bLACK
                                                  , image = listArray ((0,0,0)
                                                                      ,(y,x,3))
                                                            (repeat 255)
                                                  , comln = comln t + 1
                                                  }

-- |Write's the turtles image to a file named fl.
new :: Turtle -> String -> String -> IO Turtle
new t xstr ystr = case ( readMaybe xstr :: Maybe Int
                       , readMaybe ystr :: Maybe Int
                       )
                  of
                    (Nothing,Nothing) -> error ("Parse error on line "
                                                ++ show (comln t)
                                                ++ ": bad new size "
                                                ++ "arguments: '" ++ xstr
                                                ++ "' '" ++ ystr ++ "'")
                                         >> exitFailure >> nEW_TURTLE
                    (Nothing,_)       -> error ("Parse error on line "
                                              ++ show (comln t)
                                                ++ ": bad new x size "
                                                ++ "argument: '" ++ xstr ++ "'")
                                         >> exitFailure >> nEW_TURTLE
                    (_,Nothing)       -> error ("Parse error on line "
                                                ++ show (comln t)
                                                ++ ": bad new y argument: '"
                                                ++ ystr ++ "'")
                                         >> exitFailure >> nEW_TURTLE
                    (Just x,Just y)   -> return
                                         $ Turtle { loc   = (0,0)
                                                  , color = bLACK
                                                  , image = listArray ((0,0,0)
                                                                      ,(y,x,3))
                                                            (repeat 255)
                                                  , comln = comln t + 1
                                                  }

-- |Write's the turtles image to a file named fl.
new t xstr ystr = case ( readMaybe xstr :: Maybe Int
                       , readMaybe ystr :: Maybe Int
                       )
                  of
                    (Nothing,Nothing) -> error ("Parse error on line "
                                                ++ show (comln t)
                                                ++ ": bad new size "
                                                ++ "arguments: '" ++ xstr
                                                ++ "' '" ++ ystr ++ "'")
                                         >> exitFailure >> nEW_TURTLE
                    (Nothing,_)       -> error ("Parse error on line "
                                              ++ show (comln t)
                                                ++ ": bad new x size "
                                                ++ "argument: '" ++ xstr ++ "'")
                                         >> exitFailure >> nEW_TURTLE
                    (_,Nothing)       -> error ("Parse error on line "
                                                ++ show (comln t)
                                                ++ ": bad new y argument: '"
                                                ++ ystr ++ "'")
                                         >> exitFailure >> nEW_TURTLE
                    (Just x,Just y)   -> return
                                         $ Turtle { loc   = (0,0)
                                                  , color = bLACK
                                                  , image = listArray ((0,0,0)
                                                                      ,(y,x,3))
                                                            (repeat 255)
                                                  , comln = comln t + 1
                                                  }

-- |Write's the turtles image to a file named fl.