-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Extra utilities for working on Data.* types. -- -- Extra utilities for working on Data.* types. @package data-extra @version 2.3.0 -- | Tuple utilities. module Data.Tuple.Extra -- | Swap tuple's elements. swap :: (t1, t) -> (t, t1) -- | Extra functions for numbers. module Data.Number.Extra -- | Round toward zero (truncate). towardZero :: (Integral b, RealFrac a) => a -> b -- | Round upwards (ceiling). towardInf :: (Integral b, RealFrac a) => a -> b -- | Round backwards (floor). towardNegInf :: (Integral b, RealFrac a) => a -> b -- | Round away from zero (ceiling if positive, floor otherwise). awayFromZero :: (Integral b, RealFrac a) => a -> b -- | Round torwards zero (if half go towards zero, otherwise up to 1). nearestTowardZero :: (Integral b, RealFrac a) => a -> b -- | Same as nearestTowardZero but to infinity instead of zero. nearestTowardInf :: (Integral b, RealFrac a) => a -> b -- | Same as nearestTowardZero but towards negative instead of zero. nearestTowardNegInf :: (Integral b, RealFrac a) => a -> b -- | Same as nearestTowardZero but rounds away from zero (by -- positive or negative). nearestAwayFromZero :: (Integral b, RealFrac a) => a -> b -- | Round up (round). nearestBanker :: (Integral b, RealFrac a) => a -> b -- | Short-hand for fromIntegral. fi :: (Integral a, Num b) => a -> b -- | Is a number rounded down 0.5? isHalf :: RealFrac a => a -> Bool -- | Short-hand for fromIntegral. Deprecated in favour of the more popular -- fi. int :: (Integral a, Num b) => a -> b -- | Extra date functions. module Data.Time.Extra -- | Get the current year. getYear :: FormatTime t => t -> Integer -- | Get the current month. getMonth :: FormatTime t => t -> Integer -- | Get the current day. getDay :: FormatTime t => t -> Integer -- | Display a time span as one time relative to another. relative :: UTCTime -> UTCTime -> Bool -> Text -- | Run a stop-watch at the start and end of a computation. stopwatch :: MonadIO m => m a -> m (a, NominalDiffTime) -- | Trivial benchmark for some monadic action. bench :: MonadIO m => Integer -> m a -> m (a, NominalDiffTime) -- | Extra functions and classes for dealing with Text. module Data.Text.Extra -- | A class for converting to Text. class ToText a toText :: ToText a => a -> Text toLazyText :: ToText a => a -> Text -- | A class for converting from Text. class FromText a fromText :: FromText a => Text -> Maybe a fromLazyText :: FromText a => Text -> Maybe a -- | Big 'em up. bigUp :: Integral a => a -> Text instance FromText String instance ToText String instance ToText Text -- | Extra functions and classes for dealing with Strings. module Data.String.Extra -- | Lower case a string. lower :: String -> String -- | Upper case a string. upper :: String -> String -- | Trim a string. trim :: [Char] -> [Char] -- | A class for converting to strings. class ToString a toString :: ToString a => a -> String instance ToString String -- | Extra functions for dealing with Bool. module Data.Bool.Extra -- | An if/else condition on the given value. bool :: (a -> b) -> (a -> b) -> (a -> Bool) -> a -> b -- | Extra functions for dealing with lists. module Data.List.Extra -- | When a list is non-null, pass it to a function, otherwise use the -- default. list :: b -> ([a] -> b) -> [a] -> b -- | Get the union of the given lists. unionOf :: Eq a => [[a]] -> [a] -- | Opposite of map. for :: [a] -> (a -> b) -> [b] -- | Maybe get the last element in the list. lastToMaybe :: [a] -> Maybe a -- | Return the first item of a list or something else. firstOr :: a -> [a] -> a -- | Get the maximum of a list or return zero. maxList :: (Num t, Ord t) => [t] -> t -- | Extra functions for dealing with Maybe. module Data.Maybe.Extra -- | When the predicate is true, return maybe the action's return value. whenMaybe :: Monad m => Bool -> m a -> m (Maybe a) -- | When a value is Just, do something with it, monadically. whenJust :: Monad m => Maybe a -> (a -> m c) -> m () -- | Return the sole element of the list or nothing. sole :: [a] -> Maybe a -- | Extra functions for dealing with Either. module Data.Either.Extra -- | A map for Either values. mapEither :: (a -> b1) -> (b -> b2) -> Either a b -> Either b1 b2 -- | Maybe get the left side of an Either. leftToMaybe :: Either a b -> Maybe a -- | Maybe get the right side of an Either. rightToMaybe :: Either a b -> Maybe b -- | Is a value Left? isLeft :: Either a b -> Bool -- | Is a value Right? isRight :: Either a b -> Bool -- | Extract the left value or a default. fromLeft :: a -> Either a b -> a -- | Extract the right value or a default. fromRight :: b -> Either a b -> b -- | When a value is Right, do something with it, monadically. whenRight :: Monad m => Either a b -> (b -> m c) -> m () -- | When a value is Left, do something with it, monadically. whenLeft :: Monad m => Either a b -> (a -> m c) -> m () -- | Extra Data.* functions. module Data.Extra