-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Minimal essentials -- -- A minimal yet powerful library of essentials, only depending on -- base. @package mini @version 0.1.0.0 -- | Representation of a structure mapping unique keys to values. The -- internal structure is an AVL tree. module Mini.Data.Map -- | A map from keys of type k to values of type a. -- -- The internal structure is an AVL tree; a tree that is always -- height-balanced (the absolute value of the level difference between -- the left and right subtrees is at most 1). data Map k a -- | <math> Map difference (matching only on keys) difference :: Ord k => Map k a -> Map k b -> Map k a -- | <math> Left-biased map intersection (matching only on keys) intersection :: Ord k => Map k a -> Map k b -> Map k a -- | <math> Left-biased map union (matching only on keys) union :: Ord k => Map k a -> Map k a -> Map k a -- | <math> The empty map empty :: Map k a -- | <math> From a tail-biased list of (key, value) pairs to -- a map with bins containing the keys and values fromList :: Ord k => [(k, a)] -> Map k a -- | <math> From a key and a value to a map with a single bin singleton :: k -> a -> Map k a -- | <math> From a map to a list of (key, value) pairs in -- key-ascending order toAscList :: Map k a -> [(k, a)] -- | <math> From a map to a list of (key, value) pairs in -- key-descending order toDescList :: Map k a -> [(k, a)] -- | <math> From a left-associative operation on keys and values, a -- starting accumulator and a map to a thing foldlWithKey :: (b -> k -> a -> b) -> b -> Map k a -> b -- | <math> From a right-associative operation on keys and values, a -- starting accumulator and a map to a thing foldrWithKey :: (k -> a -> b -> b) -> b -> Map k a -> b -- | <math> From an operation, a key and a map to the map adjusted by -- applying the operation to the value associated with the key adjust :: Ord k => (a -> a) -> k -> Map k a -> Map k a -- | <math> From a key and a map to the map without the key delete :: Ord k => k -> Map k a -> Map k a -- | <math> From a predicate and a map to the map with values -- satisfying the predicate filter :: Ord k => (a -> Bool) -> Map k a -> Map k a -- | <math> From a predicate and a map to the map with keys and -- values satisfying the predicate filterWithKey :: Ord k => (k -> a -> Bool) -> Map k a -> Map k a -- | <math> From a key, a value and a map to the map including a bin -- containing the key and the value insert :: Ord k => k -> a -> Map k a -> Map k a -- | <math> From an operation, a key and a map to the map updated by -- applying the operation to the value associated with the key (setting -- if Just, deleting if Nothing) update :: Ord k => (a -> Maybe a) -> k -> Map k a -> Map k a -- | <math> From a map and another map to whether the former is a -- submap of the latter (matching on keys and values) isSubmapOf :: (Ord k, Eq a) => Map k a -> Map k a -> Bool -- | <math> From a key and a map to the value associated with the key -- in the map lookup :: Ord k => k -> Map k a -> Maybe a -- | <math> From a map to the value associated with the maximum key -- in the map lookupMax :: Map k a -> Maybe a -- | <math> From a map to the value associated with the minimum key -- in the map lookupMin :: Map k a -> Maybe a -- | <math> From a key and a map to whether the key is in the map member :: Ord k => k -> Map k a -> Bool -- | <math> From a map to whether the map is empty null :: Map k a -> Bool -- | <math> From a map to the size of the map size :: Map k a -> Int -- | <math> From a lifting operation on keys and values and a map to -- a lifted map traverseWithKey :: Applicative f => (k -> a -> f b) -> Map k a -> f (Map k b) -- | <math> From a map to whether its internal structure is valid, -- i.e. height-balanced and ordered valid :: Ord k => Map k a -> Bool instance (GHC.Classes.Ord k, GHC.Classes.Ord a) => GHC.Classes.Ord (Mini.Data.Map.Map k a) instance (GHC.Classes.Eq k, GHC.Classes.Eq a) => GHC.Classes.Eq (Mini.Data.Map.Map k a) instance (GHC.Show.Show k, GHC.Show.Show a) => GHC.Show.Show (Mini.Data.Map.Map k a) instance GHC.Base.Functor (Mini.Data.Map.Map k) instance Data.Foldable.Foldable (Mini.Data.Map.Map k) instance Data.Traversable.Traversable (Mini.Data.Map.Map k) instance GHC.Classes.Ord k => GHC.Base.Semigroup (Mini.Data.Map.Map k a) instance GHC.Classes.Ord k => GHC.Base.Monoid (Mini.Data.Map.Map k a) -- | Representation of a structure containing unique elements. The internal -- structure is an AVL tree. module Mini.Data.Set -- | A set containing elements of type a. -- -- The internal structure is an AVL tree; a tree that is always -- height-balanced (the absolute value of the level difference between -- the left and right subtrees is at most 1). data Set a -- | <math> Set difference difference :: Ord a => Set a -> Set a -> Set a -- | <math> Set intersection intersection :: Ord a => Set a -> Set a -> Set a -- | <math> Set union union :: Ord a => Set a -> Set a -> Set a -- | <math> The empty set empty :: Set a -- | <math> From a tail-biased list of elements to a set containing -- the elements fromList :: Ord a => [a] -> Set a -- | <math> From an element to a set with a single element singleton :: a -> Set a -- | <math> From a set to a list of elements in ascending order toAscList :: Set a -> [a] -- | <math> From a set to a list of elements in descending order toDescList :: Set a -> [a] -- | <math> From an element and a set to the set without the element delete :: Ord a => a -> Set a -> Set a -- | <math> From a predicate and a set to the set with elements -- satisfying the predicate filter :: Ord a => (a -> Bool) -> Set a -> Set a -- | <math> From an element and a set to the set including the -- element insert :: Ord a => a -> Set a -> Set a -- | <math> From a set and another set to whether the former is a -- subset of the latter isSubsetOf :: Ord a => Set a -> Set a -> Bool -- | <math> From a set to the maximum element of the set lookupMax :: Set a -> Maybe a -- | <math> From a set to the minimum element of the set lookupMin :: Set a -> Maybe a -- | <math> From an element and a set to whether the element is in -- the set member :: Ord a => a -> Set a -> Bool -- | <math> From a set to whether the set is empty null :: Set a -> Bool -- | <math> From a set to the size of the set size :: Set a -> Int -- | <math> From a set to whether its internal structure is valid, -- i.e. height-balanced and ordered valid :: Ord a => Set a -> Bool instance GHC.Classes.Ord a => GHC.Classes.Ord (Mini.Data.Set.Set a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Mini.Data.Set.Set a) instance GHC.Show.Show a => GHC.Show.Show (Mini.Data.Set.Set a) instance Data.Foldable.Foldable Mini.Data.Set.Set -- | Minimal library of van Laarhoven lenses: composable polymorphic -- record updates module Mini.Lens -- | A purely functional reference for updating structures of type s -- with fields of type a to structures of type t with -- fields of type b type Lens s t a b = forall f. (Functor f) => (a -> f b) -> (s -> f t) -- | From a getter and a setter to a lens -- --
-- data Foo = Foo { _bar :: Bar } deriving Show
-- data Bar = Bar { _baz :: Int } deriving Show
--
-- bar :: Lens Foo Foo Bar Bar
-- bar = lens _bar $ \s b -> s { _bar = b }
--
-- baz :: Lens Bar Bar Int Int
-- baz = lens _baz $ \s b -> s { _baz = b }
--
lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b
-- | From a lens and a structure to the value of the field of the structure
-- referenced by the lens
--
-- -- ghci> view (bar . baz) $ Foo (Bar 73) -- 73 --view :: Lens s t a b -> s -> a -- | From a lens, an operation and a structure to the structure updated by -- applying the operation to the value of the field referenced by the -- lens -- --
-- ghci> over (bar . baz) (+ 1) $ Foo (Bar 73)
-- Foo {_bar = Bar {_baz = 74}}
--
over :: Lens s t a b -> (a -> b) -> s -> t
-- | From a lens, a value and a structure to the structure updated by
-- setting the field referenced by the lens to the value
--
--
-- ghci> set (bar . baz) 21 $ Foo (Bar 73)
-- Foo {_bar = Bar {_baz = 21}}
--
set :: Lens s t a b -> b -> s -> t
-- | The class of monad transformers
module Mini.Transformers.Class
-- | Instances should satisfy the following laws:
--
-- -- lift . pure = pure ---- --
-- lift (m >>= f) = lift m >>= (lift . f) --class MonadTrans t -- | Lift a computation from the inner monad to the transformer monad lift :: (MonadTrans t, Monad m) => m a -> t m a -- | Extension of a monad with the Either ability to interrupt a -- sequence of actions and terminate with a value module Mini.Transformers.EitherT -- | A monad with early termination type e, inner monad m, -- and return type a data EitherT e m a -- | Terminate an action sequence with the given value left :: Monad m => e -> EitherT e m a -- | Run the given action and decide what to do depending on the return -- type -- --
-- anticipate foo >>= either bar baz --anticipate :: Monad m => EitherT e m a -> EitherT e m (Either e a) -- | Unwrap an EitherT runEitherT :: EitherT e m a -> m (Either e a) instance GHC.Base.Monad m => GHC.Base.Functor (Mini.Transformers.EitherT.EitherT e m) instance GHC.Base.Monad m => GHC.Base.Applicative (Mini.Transformers.EitherT.EitherT e m) instance (GHC.Base.Monad m, GHC.Base.Monoid e) => GHC.Base.Alternative (Mini.Transformers.EitherT.EitherT e m) instance GHC.Base.Monad m => GHC.Base.Monad (Mini.Transformers.EitherT.EitherT e m) instance Mini.Transformers.Class.MonadTrans (Mini.Transformers.EitherT.EitherT e) -- | Turning strings into things module Mini.Transformers.ParserT -- | A monad for parsing symbols of type s with inner monad m -- and return type a data ParserT s m a -- | Abstract representation of a parse error for symbols of type s data ParseError s -- | Unwrap a ParserT given a string of symbols runParserT :: ParserT s m a -> [s] -> m (Either [ParseError s] (a, [s])) -- | From a predicate to a parser for symbols satisfying the predicate -- --
-- digit = sat Data.Char.isDigit -- -- spaces = Control.Applicative.many $ sat Data.Char.isSpace --sat :: Applicative m => (s -> Bool) -> ParserT s m s -- | A parser for any symbol item :: Applicative m => ParserT s m s -- | A parser for the given symbol symbol :: (Applicative m, Eq s) => s -> ParserT s m s -- | A parser for the given string of symbols string :: (Monad m, Traversable t, Eq s) => t s -> ParserT s m (t s) -- | A parser for any of the given symbols oneOf :: (Applicative m, Foldable t, Eq s) => t s -> ParserT s m s -- | A parser for any symbol excluding the given symbols noneOf :: (Applicative m, Foldable t, Eq s) => t s -> ParserT s m s -- | Turn a parser and another parser into a parser for zero or more of the -- former separated by the latter sepBy :: (Monad m, Eq s) => ParserT s m a -> ParserT s m b -> ParserT s m [a] -- | Turn a parser and another parser into a parser for one or more of the -- former separated by the latter sepBy1 :: (Monad m, Eq s) => ParserT s m a -> ParserT s m b -> ParserT s m [a] -- | Turn a parser and another parser into a parser for zero or more of the -- former separated and ended by the latter endBy :: (Monad m, Eq s) => ParserT s m a -> ParserT s m b -> ParserT s m [a] -- | Turn a parser and another parser into a parser for one or more of the -- former separated and ended by the latter endBy1 :: (Monad m, Eq s) => ParserT s m a -> ParserT s m b -> ParserT s m [a] -- | Turn a first, second and third parser into a parser for the third -- enclosed between the first and the second, returning the result of the -- third between :: Monad m => ParserT s m open -> ParserT s m close -> ParserT s m a -> ParserT s m a -- | From a default value and a parser to the parser returning the default -- value in case of failure option :: (Monad m, Eq s) => a -> ParserT s m a -> ParserT s m a instance GHC.Base.Monad m => GHC.Base.Functor (Mini.Transformers.ParserT.ParserT s m) instance GHC.Base.Monad m => GHC.Base.Applicative (Mini.Transformers.ParserT.ParserT s m) instance (GHC.Base.Monad m, GHC.Classes.Eq s) => GHC.Base.Alternative (Mini.Transformers.ParserT.ParserT s m) instance GHC.Base.Monad m => GHC.Base.Monad (Mini.Transformers.ParserT.ParserT s m) instance Mini.Transformers.Class.MonadTrans (Mini.Transformers.ParserT.ParserT s) instance GHC.Show.Show s => GHC.Show.Show (Mini.Transformers.ParserT.ParseError s) -- | Extension of a monad with a read-only environment module Mini.Transformers.ReaderT -- | A monad with read-only type r, inner monad m, and return -- type a data ReaderT r m a -- | Fetch the read-only value -- --
-- foo = do -- r <- ask -- bar r --ask :: Monad m => ReaderT r m r -- | Unwrap a ReaderT given a read-only value runReaderT :: ReaderT r m a -> r -> m a instance GHC.Base.Monad m => GHC.Base.Functor (Mini.Transformers.ReaderT.ReaderT r m) instance GHC.Base.Monad m => GHC.Base.Applicative (Mini.Transformers.ReaderT.ReaderT r m) instance (GHC.Base.Monad m, GHC.Base.Alternative m) => GHC.Base.Alternative (Mini.Transformers.ReaderT.ReaderT r m) instance GHC.Base.Monad m => GHC.Base.Monad (Mini.Transformers.ReaderT.ReaderT r m) instance Mini.Transformers.Class.MonadTrans (Mini.Transformers.ReaderT.ReaderT r) -- | Extension of a monad with a modifiable environment module Mini.Transformers.StateT -- | A monad with modifiable type s, inner monad m, and -- return type a data StateT s m a -- | Fetch the current value of the state -- --
-- foo = do -- s <- get -- bar s --get :: Monad m => StateT s m s -- | Update the current value of the state with the given operation -- --
-- foo = modify $ \s -> bar s --modify :: Monad m => (s -> s) -> StateT s m () -- | Set the state to the given value put :: Monad m => s -> StateT s m () -- | Unwrap a StateT given a starting state runStateT :: StateT s m a -> s -> m (a, s) instance GHC.Base.Monad m => GHC.Base.Functor (Mini.Transformers.StateT.StateT s m) instance GHC.Base.Monad m => GHC.Base.Applicative (Mini.Transformers.StateT.StateT s m) instance (GHC.Base.Monad m, GHC.Base.Alternative m) => GHC.Base.Alternative (Mini.Transformers.StateT.StateT s m) instance GHC.Base.Monad m => GHC.Base.Monad (Mini.Transformers.StateT.StateT s m) instance Mini.Transformers.Class.MonadTrans (Mini.Transformers.StateT.StateT s) -- | Extension of a monad with a write-only environment module Mini.Transformers.WriterT -- | A monad with monoidal write-only type w, inner monad m, -- and return type a data WriterT w m a -- | Append the given value to the output tell :: Monad m => w -> WriterT w m () -- | Unwrap a WriterT runWriterT :: WriterT w m a -> m (a, w) instance (GHC.Base.Monad m, GHC.Base.Monoid w) => GHC.Base.Functor (Mini.Transformers.WriterT.WriterT w m) instance (GHC.Base.Monad m, GHC.Base.Monoid w) => GHC.Base.Applicative (Mini.Transformers.WriterT.WriterT w m) instance (GHC.Base.Monad m, GHC.Base.Alternative m, GHC.Base.Monoid w) => GHC.Base.Alternative (Mini.Transformers.WriterT.WriterT w m) instance (GHC.Base.Monad m, GHC.Base.Monoid w) => GHC.Base.Monad (Mini.Transformers.WriterT.WriterT w m) instance GHC.Base.Monoid w => Mini.Transformers.Class.MonadTrans (Mini.Transformers.WriterT.WriterT w)