matterhorn-90000.0.0: Terminal client for the Mattermost chat system
Safe HaskellSafe-Inferred
LanguageHaskell2010

Matterhorn.Config.Schema

Contents

Description

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

Documentation

(<!>) :: Parser e t a -> Parser e t a -> Parser e t a Source #

data Fatal Source #

Instances

Instances details
Show Fatal Source # 
Instance details

Defined in Matterhorn.Config.Schema

Methods

showsPrec :: Int -> Fatal -> ShowS #

show :: Fatal -> String #

showList :: [Fatal] -> ShowS #

data Warning Source #

Instances

Instances details
Show Warning Source # 
Instance details

Defined in Matterhorn.Config.Schema

section :: Text -> SectionParser a -> IniParser a Source #

sectionMb :: Text -> SectionParser a -> IniParser (Maybe a) Source #

fieldMbOf :: Text -> (Text -> Either String a) -> SectionParser (Maybe a) Source #

fieldMb :: Text -> SectionParser (Maybe Text) Source #

field :: Text -> SectionParser Text Source #

fieldDefOf :: Text -> (Text -> Either String a) -> a -> SectionParser a Source #

fieldFlagDef :: Text -> Bool -> SectionParser Bool 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"