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

Provide additional convenience helper functions #7

Open
Chratho opened this issue May 13, 2013 · 0 comments
Open

Provide additional convenience helper functions #7

Chratho opened this issue May 13, 2013 · 0 comments

Comments

@Chratho
Copy link

Chratho commented May 13, 2013

To make the libraray even more convenient to use, some helpers similiar to the following would be highly appreciated:

-- ^Retrieve with default value
getDef :: MonadError CPError m =>  ConfigParser ->  SectionSpec ->  OptionSpec ->  a ->  m a
getDef cp s o d = if has_option cp s o then get cp s o else return d
-- ^Retrieve as optional
getOpt :: MonadError CPError m =>  ConfigParser ->  SectionSpec ->  OptionSpec ->  m (Maybe a)
getOpt cp s o = if has_option cp s o then liftM Just (get cp s o) else return Nothing
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