Copyright | (c) Masahiro Sakai 2016-2018 |
---|---|
License | BSD-style |
Maintainer | masahiro.sakai@gmail.com |
Stability | provisional |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Extensions |
|
ToySolver.FileFormat.Base
Contents
Description
Synopsis
- class FileFormat a where
- data ParseError = ParseError String
- parseFile :: (FileFormat a, MonadIO m) => FilePath -> m (Either String a)
- readFile :: (FileFormat a, MonadIO m) => FilePath -> m a
- writeFile :: (FileFormat a, MonadIO m) => FilePath -> a -> m ()
FileFormat class
class FileFormat a where Source #
A type class that abstracts file formats
Methods
parse :: ByteString -> Either String a Source #
Parse a lazy byte string, and either returns error message or a parsed value
render :: a -> Builder Source #
Encode a value into Builder
Instances
data ParseError Source #
ParseError
represents a parse error and it wraps a error message.
Constructors
ParseError String |
Instances
Exception ParseError Source # | |
Defined in ToySolver.FileFormat.Base Methods toException :: ParseError -> SomeException # fromException :: SomeException -> Maybe ParseError # displayException :: ParseError -> String # | |
Show ParseError Source # | |
Defined in ToySolver.FileFormat.Base Methods showsPrec :: Int -> ParseError -> ShowS # show :: ParseError -> String # showList :: [ParseError] -> ShowS # |
parseFile :: (FileFormat a, MonadIO m) => FilePath -> m (Either String a) Source #
Parse a file but returns an error message when parsing fails.
readFile :: (FileFormat a, MonadIO m) => FilePath -> m a Source #
Parse a file. Similar to parseFile
but this function throws ParseError
when parsing fails.