Copyright | (c) Masahiro Sakai 2016-2018 |
---|---|
License | BSD-style |
Maintainer | masahiro.sakai@gmail.com |
Stability | provisional |
Portability | non-portable |
Safe Haskell | Safe |
Language | Haskell2010 |
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
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
FileFormat Formula Source # | |
FileFormat SoftFormula Source # | |
Defined in ToySolver.FileFormat parse :: ByteString -> Either String SoftFormula Source # render :: SoftFormula -> Builder Source # | |
FileFormat QDimacs Source # | |
FileFormat GCNF Source # | |
FileFormat WCNF Source # | |
FileFormat CNF Source # | |
FileFormat (Problem Scientific) Source # | |
Defined in ToySolver.QUBO parse :: ByteString -> Either String (Problem Scientific) Source # |
data ParseError Source #
ParseError
represents a parse error and it wraps a error message.
Instances
Show ParseError Source # | |
Defined in ToySolver.FileFormat.Base showsPrec :: Int -> ParseError -> ShowS # show :: ParseError -> String # showList :: [ParseError] -> ShowS # | |
Exception ParseError Source # | |
Defined in ToySolver.FileFormat.Base toException :: ParseError -> SomeException # fromException :: SomeException -> Maybe ParseError # displayException :: ParseError -> String # |
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.