[Haskell-beginners] Handling a MonadError
Christopher Howard
christopher.howard at frigidcode.com
Mon May 30 05:05:15 CEST 2011
Hi. I'm trying to learn Data.ConfigFile. I want to use the function
readfile:
[DESCRIPTION]
readfile :: MonadError CPError m => ConfigParser -> FilePath -> IO (m
ConfigParser)
Loads data from the specified file. It is then combined with the given
ConfigParser using the semantics documented under merge with the new
data taking precedence over the old. However, unlike merge, all the
options as set in the old object are preserved since the on-disk
representation does not convey those options.
May return an error if there is a syntax error. May raise an exception
if the file could not be accessed.
[/DESCRIPTION]
I understand that this function returns a monad, and I pull the value
out of it with (<-). And I believe this is similar to a "Maybe"
situation where I can do one thing if it provides a syntax error and
another thing if it provides the ConfigParser. But I'm not sure what
this would look like in actual code. Could somebody give me a small,
simple example?
--
frigidcode.com
theologia.indicium.us
More information about the Beginners
mailing list