hourglass-fuzzy-parsing-0.1.0.0: A small library for parsing more human friendly date/time formats.

Safe HaskellNone
LanguageHaskell98

Data.Hourglass.FuzzyParsing.Internal

Synopsis

Documentation

tryRead :: (Read a, Stream s m Char) => String -> ParsecT s st m a Source

Parser version of Prelude.read

tryReadInt :: (Stream s m Char, Num a) => String -> ParsecT s st m a Source

times :: Stream s m Char => Int -> ParsecT s st m t -> ParsecT s st m [t] Source

Apply parser N times

number Source

Arguments

:: (Stream s m Char, Num a, Ord a) 
=> Int

Number of digits

-> a

Maximum value

-> ParsecT s st m a 

Parse natural number of N digits which is not greater than M

pYear :: Stream s m Char => ParsecT s st m Int Source

pDay :: Stream s m Char => ParsecT s st m Int Source

isPrefixOfI :: String -> String -> Bool Source

Case-insensitive version of isPrefixOf

uniqFuzzyMatch Source

Arguments

:: (Bounded a, Enum a, Show a) 
=> String 
-> Either [a] a

Either collection of matches or the unique match

Use a data type's Bounded, Enum and Show instances to determine if the given string uniquely matches a constructor. The comparison is case-insensitive and starts from the beginning of the strings (so a partial constructor name can still match if there are enough characters for a unique match)

For example:

 data Things = Foo | Bar | Baz deriving (Bounded, Enum, Show)

 -- Right Foo
 uniqFuzzyMatch "f" :: Either [Things] Things

 -- Left [Bar, Baz]
 uniqFuzzyMatch "ba" :: Either [Things] Things