bmit :: Label -> Label -> IORef Bool -> IORef String -> IO ()
submit mainLabel sideLabel hasAnswer lastAnswer = do
    expr <- labelGetText mainLabel
    case parse expr of
        Left e ->
            let start = max 0 $ sourceColumn (errorPos e) - 2
                end = length expr
            in labelSetAttributes
               mainLabel
               [ AttrUnderlineColor start end (Color 65535 0 0)
               , AttrUnderline start end UnderlineError
               , AttrWeight 0 end WeightBold
               , AttrSize 0 end 12]
        Right val -> do
            let ans = case evaluate val of
                    Just n -> show n
                    Nothing -> "NaN"
            writeIORef hasAnswer True
            writeIORef lastAnswer ans
            labelSetText sideLabel expr
            setMainLabelText mainLabel ans


submit :: Label -> Label -> IORef Bool -> IORef String -> IO ()
submit mainLabel sideLabel hasAnswer lastAnswer = do
    expr <- labelGetText mainLabel
    case parse expr of
        Left e ->
            let start = max 0 $ sourceColumn (errorPos e) - 2
                end = length expr
            in labelSetAttributes
               mainLabel
               [ AttrUnderlineColor start end (Color 65535 0 0)
               , AttrUnderline start end UnderlineError
               , AttrWeight 0 end WeightBold
               , AttrSize 0 end 12]
        Right val -> do
            let ans = case evaluate val of
                    Just n -> show n
                    Nothing -> "NaN"
            writeIORef hasAnswer True
            writeIORef lastAnswer ans
            labelSetText sideLabel expr
            setMainLabelText mainLabel ans
submit mainLabel sideLabel hasAnswer lastAnswer = do
    expr <- labelGetText mainLabel
    case parse expr of
        Left e ->
            let start = max 0 $ sourceColumn (errorPos e) - 2
                end = length expr
            in labelSetAttributes
               mainLabel
               [ AttrUnderlineColor start end (Color 65535 0 0)
               , AttrUnderline start end UnderlineError
               , AttrWeight 0 end WeightBold
               , AttrSize 0 end 12]
        Right val -> do
            let ans = case evaluate val of
                    Just n -> show n
                    Nothing -> "NaN"
            writeIORef hasAnswer True
            writeIORef lastAnswer ans
            labelSetText sideLabel expr
            setMainLabelText mainLabel ans