-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Provides some classes and types for dealing with text, using the fundaments of Chatty. -- -- Provides some classes and types for dealing with text, using the -- fundaments of Chatty. Mainly two parser monads and a typesetter. @package chatty-text @version 0.6 -- | Provides the ChParser typeclass and some methods for input parsing. module Text.Chatty.Parser -- | Typeclass for input parsing. class ChScanner m => ChParser m pabort :: ChParser m => m a (??) :: (ChParser m, Eq a) => m a -> m a -> m a (???) :: ChParser m => m a -> m a -> m a ptry :: (ChParser m, MonadPlus n) => m a -> m (n a) -- | An prettier alias for mscan1. It scans and removes the next -- available character. request :: ChScanner m => m Char -- | Scan the next character and abort if it does not match the given one. match :: ChParser m => Char -> m Char -- | Try to match all of the given characters. Abort otherwise. matchs :: ChParser m => String -> m String -- | Try to match a whitespace. Abort otherwise. white :: ChParser m => m Char -- | Try to match a digit. Abort otherwise. digit :: ChParser m => m Int -- | Try to match a letter. Abort otherwise. alpha :: ChParser m => m Char -- | Try to match a letter or digit. Abort otherwise. anum :: ChParser m => m Char -- | Try to run the given parsing function. Return Nothing -- otherwise. possibly :: ChParser m => m a -> m (Maybe a) -- | Try to run the given parsing function as often as possible. many :: ChParser m => m a -> m [a] -- | Try to run the given parsing function as often as possible, but at -- least once. Abort otherwise. some :: ChParser m => m a -> m [a] -- | Try to match a natural decimal number. number :: ChParser m => m Int -- | Try to match a fractional number. fract :: ChParser m => m Double -- | Provides a nondeterministic MonadParser instance. module Text.Chatty.Parser.Carrier data CarrierT m a Carry :: (String -> m (a, String)) -> CarrierT m a carry :: CarrierT m a -> String -> m (a, String) -- | Run a CarrierT with its full input string. runCarrierT :: (MonadPlus m, Foldable m) => String -> CarrierT m a -> m a -- | Embed the CarrierT into a running MonadScanner -- instance. embedCarrierT :: (MonadPlus n, Foldable n, ChScanner m) => CarrierT n a -> m (n a) instance (MonadPlus m, Foldable m) => ChParser (CarrierT m) instance (MonadPlus m, Foldable m) => ChScanner (CarrierT m) instance (MonadPlus m, Foldable m) => Monoid (CarrierT m a) instance (MonadPlus m, Foldable m) => MonadPlus (CarrierT m) instance (MonadPlus m, Foldable m) => Alternative (CarrierT m) instance (MonadPlus m, Foldable m) => Applicative (CarrierT m) instance (MonadPlus m, Foldable m) => Functor (CarrierT m) instance (MonadPlus m, Foldable m) => Monad (CarrierT m) -- | Provides a nondeterministic ChParser instance. module Text.Chatty.Parser.Nondeterministic -- | A nondeterministic parsing monad. Works by keeping multiple forks -- until they fail. May return multiple solutions. First parameter should -- be an instance of MonadPlus and Foldable. data ForkerT m a Result :: (m a) -> (Char -> ForkerT m a) -> ForkerT m a Failed :: ForkerT m a -- | Feed the ForkerT with a single input character. feedForkerT1 :: (MonadPlus m, Foldable m) => Char -> ForkerT m a -> ForkerT m a -- | Feed the ForkerT with some input string. feedForkerT :: (MonadPlus m, Foldable m) => String -> ForkerT m a -> ForkerT m a -- | Embed the ForkerT into a running MonadScanner -- instance. embedForkerT :: (MonadPlus n, Foldable n, ChScanner m) => ForkerT n a -> m (n a) instance (MonadPlus m, Foldable m) => ChScanner (ForkerT m) instance (MonadPlus m, Foldable m) => ChParser (ForkerT m) instance (MonadPlus m, Foldable m) => Monad (ForkerT m) -- | Provides functions that typeset the input to a limited output width -- (to avoid ugly word cuts). module Text.Chatty.Typograph -- | Simple flush-left typesetter without support for syllabification. simpleTypesetter :: (Functor m, ChScanner m, ChPrinter m) => Int -> m () -- | Backtracking flush-left typesetter using the given hyphenator -- function. leftTypesetter :: (Functor m, ChScanner m, ChPrinter m) => Int -> (String -> [String]) -> m ()