Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GhcException for non-English messages #172

Open
ed-o-saurus opened this issue Mar 22, 2024 · 0 comments
Open

GhcException for non-English messages #172

ed-o-saurus opened this issue Mar 22, 2024 · 0 comments

Comments

@ed-o-saurus
Copy link

If the locale field LC_MESSAGES is set to a non-English language, Hint produces an GhcException.

The following demonstrates the bug. If LC_MESSAGES is set to "C" or "en_US.UTF-8", the program completes normally. Otherwise, there is an error. This program assumes that the system on which it's running supports the fr_FR locale. A list of available locales can be obtained by running locale -a on the command-line.

import System.Locale.SetLocale (setLocale, Category(LC_MESSAGES))
import Language.Haskell.Interpreter (InterpreterError (GhcException, NotAllowed, UnknownError, WontCompile), errMsg, runInterpreter)

main = do
--    locale <- setLocale LC_MESSAGES $ Just "C"           -- This works
    locale <- setLocale LC_MESSAGES $ Just "fr_FR.UTF-8"   -- This fails
    case locale of
       Nothing -> putStrLn "Unable to set LC_MESSAGES"
       Just lc_messages -> putStrLn $ "LC_MESSAGES = " ++ lc_messages
    r <- runInterpreter $ return ()
    case r of
        Left (UnknownError msg)    -> putStrLn $ "UnknownError : " ++ msg
        Left (WontCompile [])      -> putStrLn "WontCompile"
        Left (WontCompile (err:_)) -> putStrLn $ "WontCompile : " ++ (errMsg err)
        Left (NotAllowed msg)      -> putStrLn $ "NotAllowed : " ++ msg
        Left (GhcException msg)    -> putStrLn $ "GhcException : " ++ msg
        Right ()                   -> putStrLn "Success"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant