papa-base-export-0.4: Prelude with only useful functions

Synopsis

# Documentation

class Functor (f :: * -> *) where #

The Functor class is used for types that can be mapped over. Instances of Functor should satisfy the following laws:

fmap id  ==  id
fmap (f . g)  ==  fmap f . fmap g

The instances of Functor for lists, Maybe and IO satisfy these laws.

Minimal complete definition

fmap

Methods

fmap :: (a -> b) -> f a -> f b #

Instances

 Functor [] Since: 2.1 Methodsfmap :: (a -> b) -> [a] -> [b] #(<$) :: a -> [b] -> [a] # Since: 2.1 Methodsfmap :: (a -> b) -> Maybe a -> Maybe b #(<$) :: a -> Maybe b -> Maybe a # Since: 2.1 Methodsfmap :: (a -> b) -> IO a -> IO b #(<$) :: a -> IO b -> IO a # Since: 4.9.0.0 Methodsfmap :: (a -> b) -> Min a -> Min b #(<$) :: a -> Min b -> Min a # Since: 4.9.0.0 Methodsfmap :: (a -> b) -> Max a -> Max b #(<$) :: a -> Max b -> Max a # Since: 4.9.0.0 Methodsfmap :: (a -> b) -> First a -> First b #(<$) :: a -> First b -> First a # Since: 4.9.0.0 Methodsfmap :: (a -> b) -> Last a -> Last b #(<$) :: a -> Last b -> Last a # Since: 4.9.0.0 Methodsfmap :: (a -> b) -> Option a -> Option b #(<$) :: a -> Option b -> Option a # Since: 4.9.0.0 Methodsfmap :: (a -> b) -> NonEmpty a -> NonEmpty b #(<$) :: a -> NonEmpty b -> NonEmpty a # Methodsfmap :: (a -> b) -> ZipList a -> ZipList b #(<$) :: a -> ZipList b -> ZipList a # Since: 4.8.0.0 Methodsfmap :: (a -> b) -> Dual a -> Dual b #(<$) :: a -> Dual b -> Dual a # Since: 4.8.0.0 Methodsfmap :: (a -> b) -> Sum a -> Sum b #(<$) :: a -> Sum b -> Sum a # Since: 4.8.0.0 Methodsfmap :: (a -> b) -> Product a -> Product b #(<$) :: a -> Product b -> Product a # Methodsfmap :: (a -> b) -> First a -> First b #(<$) :: a -> First b -> First a # Methodsfmap :: (a -> b) -> Last a -> Last b #(<$) :: a -> Last b -> Last a # Since: 3.0 Methodsfmap :: (a -> b) -> Either a a -> Either a b #(<$) :: a -> Either a b -> Either a a # Functor ((,) a) Since: 2.1 Methodsfmap :: (a -> b) -> (a, a) -> (a, b) #(<$) :: a -> (a, b) -> (a, a) # Functor (Arg a) Since: 4.9.0.0 Methodsfmap :: (a -> b) -> Arg a a -> Arg a b #(<$) :: a -> Arg a b -> Arg a a # Monad m => Functor (WrappedMonad m) Since: 2.1 Methodsfmap :: (a -> b) -> WrappedMonad m a -> WrappedMonad m b #(<$) :: a -> WrappedMonad m b -> WrappedMonad m a # Arrow a => Functor (WrappedArrow a b) Since: 2.1 Methodsfmap :: (a -> b) -> WrappedArrow a b a -> WrappedArrow a b b #(<$) :: a -> WrappedArrow a b b -> WrappedArrow a b a # Since: 2.1 Methodsfmap :: (a -> b) -> Const * m a -> Const * m b #(<$) :: a -> Const * m b -> Const * m a # Functor f => Functor (Alt * f) Methodsfmap :: (a -> b) -> Alt * f a -> Alt * f b #(<$) :: a -> Alt * f b -> Alt * f a # Functor ((->) LiftedRep LiftedRep r) Since: 2.1 Methodsfmap :: (a -> b) -> (LiftedRep -> LiftedRep) r a -> (LiftedRep -> LiftedRep) r b #(<$) :: a -> (LiftedRep -> LiftedRep) r b -> (LiftedRep -> LiftedRep) r a # class Applicative m => Monad (m :: * -> *) where # The Monad class defines the basic operations over a monad, a concept from a branch of mathematics known as category theory. From the perspective of a Haskell programmer, however, it is best to think of a monad as an abstract datatype of actions. Haskell's do expressions provide a convenient syntax for writing monadic expressions. Instances of Monad should satisfy the following laws: • return a >>= k = k a • m >>= return = m • m >>= (\x -> k x >>= h) = (m >>= k) >>= h Furthermore, the Monad and Applicative operations should relate as follows: • pure = return • (<*>) = ap The above laws imply: • fmap f xs = xs >>= return . f • (>>) = (*>) and that pure and (<*>) satisfy the applicative functor laws. The instances of Monad for lists, Maybe and IO defined in the Prelude satisfy these laws. Minimal complete definition (>>=) Methods (>>=) :: m a -> (a -> m b) -> m b infixl 1 # Sequentially compose two actions, passing any value produced by the first as an argument to the second. (>>) :: m a -> m b -> m b infixl 1 # Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages. return :: a -> m a # Inject a value into the monadic type. Instances  Monad [] Since: 2.1 Methods(>>=) :: [a] -> (a -> [b]) -> [b] #(>>) :: [a] -> [b] -> [b] #return :: a -> [a] #fail :: String -> [a] # Since: 2.1 Methods(>>=) :: Maybe a -> (a -> Maybe b) -> Maybe b #(>>) :: Maybe a -> Maybe b -> Maybe b #return :: a -> Maybe a #fail :: String -> Maybe a # Since: 2.1 Methods(>>=) :: IO a -> (a -> IO b) -> IO b #(>>) :: IO a -> IO b -> IO b #return :: a -> IO a #fail :: String -> IO a # Since: 4.9.0.0 Methods(>>=) :: Min a -> (a -> Min b) -> Min b #(>>) :: Min a -> Min b -> Min b #return :: a -> Min a #fail :: String -> Min a # Since: 4.9.0.0 Methods(>>=) :: Max a -> (a -> Max b) -> Max b #(>>) :: Max a -> Max b -> Max b #return :: a -> Max a #fail :: String -> Max a # Since: 4.9.0.0 Methods(>>=) :: First a -> (a -> First b) -> First b #(>>) :: First a -> First b -> First b #return :: a -> First a #fail :: String -> First a # Since: 4.9.0.0 Methods(>>=) :: Last a -> (a -> Last b) -> Last b #(>>) :: Last a -> Last b -> Last b #return :: a -> Last a #fail :: String -> Last a # Since: 4.9.0.0 Methods(>>=) :: Option a -> (a -> Option b) -> Option b #(>>) :: Option a -> Option b -> Option b #return :: a -> Option a #fail :: String -> Option a # Since: 4.9.0.0 Methods(>>=) :: NonEmpty a -> (a -> NonEmpty b) -> NonEmpty b #(>>) :: NonEmpty a -> NonEmpty b -> NonEmpty b #return :: a -> NonEmpty a #fail :: String -> NonEmpty a # Since: 4.8.0.0 Methods(>>=) :: Dual a -> (a -> Dual b) -> Dual b #(>>) :: Dual a -> Dual b -> Dual b #return :: a -> Dual a #fail :: String -> Dual a # Since: 4.8.0.0 Methods(>>=) :: Sum a -> (a -> Sum b) -> Sum b #(>>) :: Sum a -> Sum b -> Sum b #return :: a -> Sum a #fail :: String -> Sum a # Since: 4.8.0.0 Methods(>>=) :: Product a -> (a -> Product b) -> Product b #(>>) :: Product a -> Product b -> Product b #return :: a -> Product a #fail :: String -> Product a # Methods(>>=) :: First a -> (a -> First b) -> First b #(>>) :: First a -> First b -> First b #return :: a -> First a #fail :: String -> First a # Methods(>>=) :: Last a -> (a -> Last b) -> Last b #(>>) :: Last a -> Last b -> Last b #return :: a -> Last a #fail :: String -> Last a # Monad (Either e) Since: 4.4.0.0 Methods(>>=) :: Either e a -> (a -> Either e b) -> Either e b #(>>) :: Either e a -> Either e b -> Either e b #return :: a -> Either e a #fail :: String -> Either e a # Monoid a => Monad ((,) a) Since: 4.9.0.0 Methods(>>=) :: (a, a) -> (a -> (a, b)) -> (a, b) #(>>) :: (a, a) -> (a, b) -> (a, b) #return :: a -> (a, a) #fail :: String -> (a, a) # Monad m => Monad (WrappedMonad m) Methods(>>=) :: WrappedMonad m a -> (a -> WrappedMonad m b) -> WrappedMonad m b #(>>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b #return :: a -> WrappedMonad m a #fail :: String -> WrappedMonad m a # Monad f => Monad (Alt * f) Methods(>>=) :: Alt * f a -> (a -> Alt * f b) -> Alt * f b #(>>) :: Alt * f a -> Alt * f b -> Alt * f b #return :: a -> Alt * f a #fail :: String -> Alt * f a # Monad ((->) LiftedRep LiftedRep r) Since: 2.1 Methods(>>=) :: (LiftedRep -> LiftedRep) r a -> (a -> (LiftedRep -> LiftedRep) r b) -> (LiftedRep -> LiftedRep) r b #(>>) :: (LiftedRep -> LiftedRep) r a -> (LiftedRep -> LiftedRep) r b -> (LiftedRep -> LiftedRep) r b #return :: a -> (LiftedRep -> LiftedRep) r a #fail :: String -> (LiftedRep -> LiftedRep) r a # class (Alternative m, Monad m) => MonadPlus (m :: * -> *) where # Monads that also support choice and failure. Methods mzero :: m a # the identity of mplus. It should also satisfy the equations mzero >>= f = mzero v >> mzero = mzero mplus :: m a -> m a -> m a # an associative operation Instances  Since: 2.1 Methodsmzero :: [a] #mplus :: [a] -> [a] -> [a] # Since: 2.1 Methodsmzero :: Maybe a #mplus :: Maybe a -> Maybe a -> Maybe a # Since: 4.9.0.0 Methodsmzero :: IO a #mplus :: IO a -> IO a -> IO a # Since: 4.9.0.0 Methodsmzero :: Option a #mplus :: Option a -> Option a -> Option a # MonadPlus f => MonadPlus (Alt * f) Methodsmzero :: Alt * f a #mplus :: Alt * f a -> Alt * f a -> Alt * f a # forever :: Applicative f => f a -> f b # forever act repeats the action infinitely. void :: Functor f => f a -> f () # void value discards or ignores the result of evaluation, such as the return value of an IO action. #### Examples Replace the contents of a Maybe Int with unit: >>> void Nothing Nothing >>> void (Just 3) Just ()  Replace the contents of an Either Int Int with unit, resulting in an Either Int '()': >>> void (Left 8675309) Left 8675309 >>> void (Right 8675309) Right ()  Replace every element of a list with unit: >>> void [1,2,3] [(),(),()]  Replace the second element of a pair with unit: >>> void (1,2) (1,())  Discard the result of an IO action: >>> mapM print [1,2] 1 2 [(),()] >>> void$ mapM print [1,2]
1
2


msum :: (Foldable t, MonadPlus m) => t (m a) -> m a #

The sum of a collection of actions, generalizing concat. As of base 4.8.0.0, msum is just asum, specialized to MonadPlus.

mfilter :: MonadPlus m => (a -> Bool) -> m a -> m a #

Direct MonadPlus equivalent of filter filter = (mfilter:: (a -> Bool) -> [a] -> [a] applicable to any MonadPlus, for example mfilter odd (Just 1) == Just 1 mfilter odd (Just 2) == Nothing

filterM :: Applicative m => (a -> m Bool) -> [a] -> m [a] #

This generalizes the list-based filter function.

foldM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b #

The foldM function is analogous to foldl, except that its result is encapsulated in a monad. Note that foldM works from left-to-right over the list arguments. This could be an issue where (>>) and the folded function' are not commutative.

      foldM f a1 [x1, x2, ..., xm]

==

      do
a2 <- f a1 x1
a3 <- f a2 x2
...
f am xm

If right-to-left evaluation is required, the input list should be reversed.

Note: foldM is the same as foldlM

foldM_ :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m () #

Like foldM, but discards the result.

replicateM :: Applicative m => Int -> m a -> m [a] #

replicateM n act performs the action n times, gathering the results.

replicateM_ :: Applicative m => Int -> m a -> m () #

Like replicateM, but discards the result.

guard :: Alternative f => Bool -> f () #

guard b is pure () if b is True, and empty if b is False.

when :: Applicative f => Bool -> f () -> f () #

Conditional execution of Applicative expressions. For example,

when debug (putStrLn "Debugging")

will output the string Debugging if the Boolean value debug is True, and otherwise do nothing.

unless :: Applicative f => Bool -> f () -> f () #

The reverse of when.

(<$!>) :: Monad m => (a -> b) -> m a -> m b infixl 4 # Strict version of <$>`.

Since: 4.8.0.0