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

Poor error messages for bool variables #45

Open
robx opened this issue Sep 7, 2021 · 2 comments
Open

Poor error messages for bool variables #45

robx opened this issue Sep 7, 2021 · 2 comments

Comments

@robx
Copy link

robx commented Sep 7, 2021

Parsing a bool variable, not only does "true" not work as a value, but the error message is not helpful in finding out that I should specify "True":

Parse failure: could not parse variable "TEST_BOOL" into type [Char]
@dmjio
Copy link
Owner

dmjio commented Sep 7, 2021

yea, it just uses the Read instance for Bool.

instance Var Bool where toVar = show; fromVar = readMaybe

@dmjio
Copy link
Owner

dmjio commented Sep 12, 2021

You can make your own though.

newtype Thing = Thing Bool
 
instance FromEnv Thing where
  fromEnv _ = fmap Thing $ (True <$ (env "true" <|> env "True")) <|> (False <$ (env "false" <|> env "False"))

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

2 participants