Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module provides an INI schema validator that is able to track unused sections and fields in order to report warning messages to the user.
Synopsis
- type IniParser = Parser RawIni IniSection
- parseIniFile :: Text -> IniParser a -> Either Fatal ([Warning], a)
- (<!>) :: Parser e t a -> Parser e t a -> Parser e t a
- data Fatal
- fatalString :: Fatal -> String
- data Warning
- warningString :: Warning -> String
- section :: Text -> SectionParser a -> IniParser a
- sectionMb :: Text -> SectionParser a -> IniParser (Maybe a)
- fieldMbOf :: Text -> (Text -> Either String a) -> SectionParser (Maybe a)
- fieldMb :: Text -> SectionParser (Maybe Text)
- field :: Text -> SectionParser Text
- fieldDefOf :: Text -> (Text -> Either String a) -> a -> SectionParser a
- fieldFlagDef :: Text -> Bool -> SectionParser Bool
- number :: (Num a, Read a, Typeable a) => Text -> Either String a
- string :: IsString a => Text -> Either String a
- listWithSeparator :: IsList l => Text -> (Text -> Either String (Item l)) -> Text -> Either String l
Documentation
type IniParser = Parser RawIni IniSection Source #
fatalString :: Fatal -> String Source #
warningString :: Warning -> String Source #
Re-exports
number :: (Num a, Read a, Typeable a) => Text -> Either String a #
Try to use the Read instance for a numeric type to parse a value, failing with a human-readable error message if reading fails.
>>>
number "5" :: Either String Int
Right 5>>>
number "hello" :: Either String Int
Left "Unable to parse \"hello\" as a value of type Int"
string :: IsString a => Text -> Either String a #
Convert a textual value to the appropriate string type. This will never fail.
>>>
string "foo" :: Either String String
Right "foo"
listWithSeparator :: IsList l => Text -> (Text -> Either String (Item l)) -> Text -> Either String l #
Convert a reader for a value into a reader for a list of those values, separated by a chosen separator. This will split apart the string on that separator, get rid of leading and trailing whitespace on the individual chunks, and then attempt to parse each of them according to the function provided, turning the result into a list.
This is overloaded with the IsList typeclass, so it can be used transparently to parse other list-like types.
>>>
listWithSeparator "," number "2, 3, 4" :: Either String [Int]
Right [2,3,4]>>>
listWithSeparator " " number "7 8 9" :: Either String [Int]
Right [7,8,9]>>>
listWithSeparator ":" string "/bin:/usr/bin" :: Either String [FilePath]
Right ["/bin","/usr/bin"]>>>
listWithSeparator "," number "7 8 9" :: Either String [Int]
Left "Unable to parse \"7 8 9\" as a value of type Int"