parse_ln :: Turtle -> [String] -> IO Turtle
parse_ln t cs
    | null cs            = return $ t { comln = comln t + 1 } -- Empty lines.
    | head cs == "move"
      && null (tail cs)  =  error ("Parse error on line: " ++ show (comln t)
                                   ++ ": direction needed: up down left right")
    | head cs == "move"  = (move t (cs!!1) (read $ cs!!2))
                           >>= (\t' -> return $ t' { comln = comln t + 1 })
    | head cs == "color" = color_change t (cs!!1)
                           >>= (\t' -> return $ t' { comln = comln t + 1 })
    | head cs == "write" = write t (cs!!1)
    | head cs == "new" && (null (tail cs) || null (tail (tail cs)))
                         = error ("Parse error on line: " ++ show (comln t)
                                  ++ ": missing paramaters to new: x y")
                           >> exitFailure >> nEW_TURTLE
    | head cs == "new"   = new t (cs!!1) (cs!!2)
    | head cs == "--"    = return $ t { comln = comln t + 1 } -- Comments.
    | otherwise = error ("Parse error on line: " ++ show (comln t)
                         ++ ": command not recognized: '" ++ head cs ++ "'")
                  >> exitFailure >> nEW_TURTLE
parse_ln :: Turtle -> [String] -> IO Turtle
parse_ln t cs
    | null cs            = return $ t { comln = comln t + 1 } -- Empty lines.
    | head cs == "move"
      && null (tail cs)  =  error ("Parse error on line: " ++ show (comln t)
                                   ++ ": direction needed: up down left right")
    | head cs == "move"  = (move t (cs!!1) (read $ cs!!2))
                           >>= (\t' -> return $ t' { comln = comln t + 1 })
    | head cs == "color" = color_change t (cs!!1)
                           >>= (\t' -> return $ t' { comln = comln t + 1 })
    | head cs == "write" = write t (cs!!1)
    | head cs == "new" && (null (tail cs) || null (tail (tail cs)))
                         = error ("Parse error on line: " ++ show (comln t)
                                  ++ ": missing paramaters to new: x y")
                           >> exitFailure >> nEW_TURTLE
    | head cs == "new"   = new t (cs!!1) (cs!!2)
    | head cs == "--"    = return $ t { comln = comln t + 1 } -- Comments.
    | otherwise = error ("Parse error on line: " ++ show (comln t)
                         ++ ": command not recognized: '" ++ head cs ++ "'")
                  >> exitFailure >> nEW_TURTLE
parse_ln t cs
    | null cs            = return $ t { comln = comln t + 1 } -- Empty lines.
    | head cs == "move"
      && null (tail cs)  =  error ("Parse error on line: " ++ show (comln t)
                                   ++ ": direction needed: up down left right")
    | head cs == "move"  = (move t (cs!!1) (read $ cs!!2))
                           >>= (\t' -> return $ t' { comln = comln t + 1 })
    | head cs == "color" = color_change t (cs!!1)
                           >>= (\t' -> return $ t' { comln = comln t + 1 })
    | head cs == "write" = write t (cs!!1)
    | head cs == "new" && (null (tail cs) || null (tail (tail cs)))
                         = error ("Parse error on line: " ++ show (comln t)
                                  ++ ": missing paramaters to new: x y")
                           >> exitFailure >> nEW_TURTLE
    | head cs == "new"   = new t (cs!!1) (cs!!2)
    | head cs == "--"    = return $ t { comln = comln t + 1 } -- Comments.
    | otherwise = error ("Parse error on line: " ++ show (comln t)
                         ++ ": command not recognized: '" ++ head cs ++ "'")
                  >> exitFailure >> nEW_TURTLE