Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type String = [Char]
- error :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => [Char] -> a
- head :: HasCallStack => [a] -> a
- last :: HasCallStack => [a] -> a
- type HasCallStack = ?callStack :: CallStack
- type HasDebugCallStack = ()
- data Direction
- type Suffix = String
- split :: Char -> String -> [String]
- dropWhileEndLE :: (a -> Bool) -> [a] -> [a]
- ordNub :: Ord a => [a] -> [a]
- singleton :: a -> [a]
- fstOf3 :: (a, b, c) -> a
- sndOf3 :: (a, b, c) -> b
- count :: (a -> Bool) -> [a] -> Int
- lengthAtLeast :: [a] -> Int -> Bool
- foldl1' :: HasCallStack => (a -> a -> a) -> [a] -> a
- applyWhen :: Bool -> (a -> a) -> a -> a
- sortWith :: Ord b => (a -> b) -> [a] -> [a]
- mkNoRepType :: String -> DataType
- spanEnd :: (a -> Bool) -> [a] -> ([a], [a])
- compareLength :: [a] -> [b] -> Ordering
- dropList :: [b] -> [a] -> [a]
- (<&&>) :: Applicative f => f Bool -> f Bool -> f Bool
- (<||>) :: Applicative f => f Bool -> f Bool -> f Bool
- unzipWith :: (a -> b -> c) -> [(a, b)] -> [c]
- notNull :: Foldable f => f a -> Bool
- nubSort :: Ord a => [a] -> [a]
- nTimes :: Int -> (a -> a) -> a -> a
- const2 :: a -> b -> c -> a
- thdOf3 :: (a, b, c) -> c
- filterOut :: (a -> Bool) -> [a] -> [a]
- partitionWith :: (a -> Either b c) -> [a] -> ([b], [c])
- chkAppend :: [a] -> [a] -> [a]
- zipEqual :: HasDebugCallStack => String -> [a] -> [b] -> [(a, b)]
- zipWithEqual :: HasDebugCallStack => String -> (a -> b -> c) -> [a] -> [b] -> [c]
- zipWith3Equal :: HasDebugCallStack => String -> (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
- zipWith4Equal :: HasDebugCallStack => String -> (a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e]
- filterByList :: [Bool] -> [a] -> [a]
- filterByLists :: [Bool] -> [a] -> [a] -> [a]
- partitionByList :: [Bool] -> [a] -> ([a], [a])
- stretchZipWith :: (a -> Bool) -> b -> (a -> b -> c) -> [a] -> [b] -> [c]
- mapFst :: Functor f => (a -> c) -> f (a, b) -> f (c, b)
- mapSnd :: Functor f => (b -> c) -> f (a, b) -> f (a, c)
- mapAndUnzip :: (a -> (b, c)) -> [a] -> ([b], [c])
- mapAndUnzip3 :: (a -> (b, c, d)) -> [a] -> ([b], [c], [d])
- zipWithAndUnzip :: (a -> b -> (c, d)) -> [a] -> [b] -> ([c], [d])
- zipAndUnzip :: [a] -> [b] -> ([a], [b])
- atLength :: ([a] -> b) -> b -> [a] -> Int -> b
- lengthExceeds :: [a] -> Int -> Bool
- lengthIs :: [a] -> Int -> Bool
- lengthIsNot :: [a] -> Int -> Bool
- lengthAtMost :: [a] -> Int -> Bool
- lengthLessThan :: [a] -> Int -> Bool
- listLengthCmp :: [a] -> Int -> Ordering
- equalLength :: [a] -> [b] -> Bool
- leLength :: [a] -> [b] -> Bool
- ltLength :: [a] -> [b] -> Bool
- isSingleton :: [a] -> Bool
- only :: [a] -> a
- expectOnly :: HasCallStack => String -> [a] -> a
- chunkList :: Int -> [a] -> [[a]]
- holes :: [a] -> [(a, [a])]
- changeLast :: [a] -> a -> [a]
- mapLastM :: Functor f => (a -> f a) -> NonEmpty a -> f (NonEmpty a)
- whenNonEmpty :: Applicative m => [a] -> (NonEmpty a -> m ()) -> m ()
- mergeListsBy :: (a -> a -> Ordering) -> [[a]] -> [a]
- isSortedBy :: (a -> a -> Ordering) -> [a] -> Bool
- minWith :: Ord b => (a -> b) -> [a] -> a
- ordNubOn :: Ord b => (a -> b) -> [a] -> [a]
- transitiveClosure :: (a -> [a]) -> (a -> a -> Bool) -> [a] -> [a]
- foldl2 :: (acc -> a -> b -> acc) -> acc -> [a] -> [b] -> acc
- all2 :: (a -> b -> Bool) -> [a] -> [b] -> Bool
- countWhile :: (a -> Bool) -> [a] -> Int
- takeList :: [b] -> [a] -> [a]
- splitAtList :: [b] -> [a] -> ([a], [a])
- dropTail :: Int -> [a] -> [a]
- last2 :: [a] -> Maybe (a, a)
- lastMaybe :: [a] -> Maybe a
- onJust :: b -> Maybe a -> (a -> b) -> b
- snocView :: [a] -> Maybe ([a], a)
- capitalise :: String -> String
- isEqual :: Ordering -> Bool
- removeSpaces :: String -> String
- fuzzyMatch :: String -> [String] -> [String]
- fuzzyLookup :: String -> [(String, a)] -> [a]
- seqList :: [a] -> b -> b
- strictMap :: (a -> b) -> [a] -> [b]
- strictZipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
- strictZipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
- looksLikeModuleName :: String -> Bool
- looksLikePackageName :: String -> Bool
- exactLog2 :: Integer -> Maybe Integer
- readRational :: String -> Rational
- readSignificandExponentPair :: String -> (Integer, Integer)
- readHexRational :: String -> Rational
- readHexSignificandExponentPair :: String -> (Integer, Integer)
- doesDirNameExist :: FilePath -> IO Bool
- getModificationUTCTime :: FilePath -> IO UTCTime
- modificationTimeIfExists :: FilePath -> IO (Maybe UTCTime)
- fileHashIfExists :: FilePath -> IO (Maybe Fingerprint)
- withAtomicRename :: MonadIO m => FilePath -> (FilePath -> m a) -> m a
- splitLongestPrefix :: String -> (Char -> Bool) -> (String, String)
- escapeSpaces :: String -> String
- reslash :: Direction -> FilePath -> FilePath
- makeRelativeTo :: FilePath -> FilePath -> FilePath
- abstractConstr :: String -> Constr
- abstractDataType :: String -> DataType
- charToC :: Word8 -> String
- hashString :: String -> Int32
- mapMaybe' :: Foldable f => (a -> Maybe b) -> f a -> [b]
- data Value
- type Object = KeyMap Value
- class FromJSON a where
- parseJSON :: Value -> Parser a
- parseJSONList :: Value -> Parser [a]
- omittedField :: Maybe a
- class ToJSON a where
- toJSON :: a -> Value
- toEncoding :: a -> Encoding
- toJSONList :: [a] -> Value
- toEncodingList :: [a] -> Encoding
- omitField :: a -> Bool
- (.:) :: FromJSON a => Object -> Key -> Parser a
- object :: [Pair] -> Value
- (.!=) :: Parser (Maybe a) -> a -> Parser a
- (.:?) :: FromJSON a => Object -> Key -> Parser (Maybe a)
- withObject :: String -> (Object -> Parser a) -> Value -> Parser a
- data Interval v = Interval v v
- low :: Interval v -> v
- high :: Interval v -> v
- point :: v -> Interval v
- newtype I a = I a
- unI :: I a -> a
- module Data.SOP.Strict
- chunksOf :: Int -> [e] -> [[e]]
- data UTCTime = UTCTime {
- utctDay :: Day
- utctDayTime :: DiffTime
- data NominalDiffTime
- addUTCTime :: NominalDiffTime -> UTCTime -> UTCTime
- diffUTCTime :: UTCTime -> UTCTime -> NominalDiffTime
- module Data.Time.Clock.POSIX
- data StrictMaybe a
- fromSMaybe :: a -> StrictMaybe a -> a
- (***) :: Arrow a => a b c -> a b' c' -> a (b, b') (c, c')
- (&&&) :: Arrow a => a b c -> a b c' -> a b (c, c')
- (<|>) :: Alternative f => f a -> f a -> f a
- mapConcurrently :: Traversable t => (a -> IO b) -> t a -> IO (t b)
- forConcurrently :: Traversable t => t a -> (a -> IO b) -> IO (t b)
- mapConcurrently_ :: Foldable f => (a -> IO b) -> f a -> IO ()
- forConcurrently_ :: Foldable f => f a -> (a -> IO b) -> IO ()
- newExceptT :: m (Either x a) -> ExceptT x m a
- firstExceptT :: forall (m :: Type -> Type) x y a. Functor m => (x -> y) -> ExceptT x m a -> ExceptT y m a
- module Ouroboros.Consensus.Util.Time
- printf :: PrintfType r => String -> r
- type SMaybe a = StrictMaybe a
- data F
- newtype RUTCTime = RUTCTime {}
- isSJust :: SMaybe a -> Bool
- isSNothing :: SMaybe a -> Bool
- strictMaybe :: Maybe a -> SMaybe a
- replaceExtension :: FilePath -> String -> FilePath
- spans :: forall a. (a -> Bool) -> [a] -> [Vector a]
- showText :: Show a => a -> Text
- unionIntv :: Ord a => [Interval a] -> Interval a
- intersectIntv :: Ord a => [Interval a] -> Interval a
- renderIntv :: (a -> Text) -> Interval a -> Text
- intvDurationSec :: Interval UTCTime -> NominalDiffTime
- smaybe :: b -> (a -> b) -> StrictMaybe a -> b
- lazySMaybe :: SMaybe a -> Maybe a
- catSMaybes :: [SMaybe a] -> [a]
- mapSMaybe :: (a -> StrictMaybe b) -> [a] -> [b]
- mapSMaybeFB :: (b -> r -> r) -> (a -> StrictMaybe b) -> a -> r -> r
- mapConcurrentlyPure :: NFData b => (a -> b) -> [a] -> IO [b]
- mapHead :: (a -> a) -> [a] -> [a]
- mapLast :: (a -> a) -> [a] -> [a]
- redistribute :: (a, (b, c)) -> ((a, b), (a, c))
- nChunksEachOf :: Int -> Int -> Text -> [Text]
- toDouble :: forall a. Real a => a -> Double
- progress :: MonadIO m => String -> F -> m ()
- norm2Tuple :: ((a, b), c) -> (a, (b, c))
- roundUTCTimeSec :: UTCTime -> UTCTime
- roundUTCTimeDay :: UTCTime -> UTCTime
- utcTimeDeltaSec :: UTCTime -> UTCTime -> Int
- foldEmpty :: r -> ([a] -> r) -> [a] -> r
- zeroUTCTime :: UTCTime
- unsafeNominalToUTC :: NominalDiffTime -> UTCTime
- unsafeUTCToNominal :: UTCTime -> NominalDiffTime
- toRUTCTime :: UTCTime -> RUTCTime
- fromRUTCTime :: RUTCTime -> UTCTime
Documentation
error :: forall (r :: RuntimeRep) (a :: TYPE r). HasCallStack => [Char] -> a Source #
error
stops execution and displays an error message.
head :: HasCallStack => [a] -> a Source #
\(\mathcal{O}(1)\). Extract the first element of a list, which must be non-empty.
>>>
head [1, 2, 3]
1>>>
head [1..]
1>>>
head []
*** Exception: Prelude.head: empty list
WARNING: This function is partial. You can use case-matching, uncons
or
listToMaybe
instead.
last :: HasCallStack => [a] -> a Source #
\(\mathcal{O}(n)\). Extract the last element of a list, which must be finite and non-empty.
>>>
last [1, 2, 3]
3>>>
last [1..]
* Hangs forever *>>>
last []
*** Exception: Prelude.last: empty list
WARNING: This function is partial. You can use reverse
with case-matching,
uncons
or listToMaybe
instead.
type HasCallStack = ?callStack :: CallStack Source #
Request a CallStack.
NOTE: The implicit parameter ?callStack :: CallStack
is an
implementation detail and should not be considered part of the
CallStack
API, we may decide to change the implementation in the
future.
Since: base-4.9.0.0
type HasDebugCallStack = () Source #
A call stack constraint, but only when isDebugOn
.
dropWhileEndLE :: (a -> Bool) -> [a] -> [a] Source #
lengthAtLeast :: [a] -> Int -> Bool Source #
(lengthAtLeast xs n) = (length xs >= n)
foldl1' :: HasCallStack => (a -> a -> a) -> [a] -> a Source #
A strict version of foldl1
.
sortWith :: Ord b => (a -> b) -> [a] -> [a] Source #
The sortWith
function sorts a list of elements using the
user supplied function to project something out of each element
In general if the user supplied function is expensive to compute then
you should probably be using sortOn
, as it only needs
to compute it once for each element. sortWith
, on the other hand
must compute the mapping function for every comparison that it performs.
mkNoRepType :: String -> DataType Source #
Constructs a non-representation for a non-representable type
spanEnd :: (a -> Bool) -> [a] -> ([a], [a]) Source #
spanEnd p l == reverse (span p (reverse l))
. The first list
returns actually comes after the second list (when you look at the
input list).
compareLength :: [a] -> [b] -> Ordering Source #
partitionWith :: (a -> Either b c) -> [a] -> ([b], [c]) Source #
Uses a function to determine which of two output lists an input element should join
zipEqual :: HasDebugCallStack => String -> [a] -> [b] -> [(a, b)] Source #
zipWithEqual :: HasDebugCallStack => String -> (a -> b -> c) -> [a] -> [b] -> [c] Source #
zipWith3Equal :: HasDebugCallStack => String -> (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d] Source #
zipWith4Equal :: HasDebugCallStack => String -> (a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e] Source #
filterByList :: [Bool] -> [a] -> [a] Source #
filterByList
takes a list of Bools and a list of some elements and
filters out these elements for which the corresponding value in the list of
Bools is False. This function does not check whether the lists have equal
length.
filterByLists :: [Bool] -> [a] -> [a] -> [a] Source #
filterByLists
takes a list of Bools and two lists as input, and
outputs a new list consisting of elements from the last two input lists. For
each Bool in the list, if it is True
, then it takes an element from the
former list. If it is False
, it takes an element from the latter list.
The elements taken correspond to the index of the Bool in its list.
For example:
filterByLists [True, False, True, False] "abcd" "wxyz" = "axcz"
This function does not check whether the lists have equal length.
partitionByList :: [Bool] -> [a] -> ([a], [a]) Source #
partitionByList
takes a list of Bools and a list of some elements and
partitions the list according to the list of Bools. Elements corresponding
to True
go to the left; elements corresponding to False
go to the right.
For example, partitionByList [True, False, True] [1,2,3] == ([1,3], [2])
This function does not check whether the lists have equal
length; when one list runs out, the function stops.
stretchZipWith :: (a -> Bool) -> b -> (a -> b -> c) -> [a] -> [b] -> [c] Source #
stretchZipWith p z f xs ys
stretches ys
by inserting z
in
the places where p
returns True
mapAndUnzip :: (a -> (b, c)) -> [a] -> ([b], [c]) Source #
mapAndUnzip3 :: (a -> (b, c, d)) -> [a] -> ([b], [c], [d]) Source #
zipWithAndUnzip :: (a -> b -> (c, d)) -> [a] -> [b] -> ([c], [d]) Source #
zipAndUnzip :: [a] -> [b] -> ([a], [b]) Source #
This has the effect of making the two lists have equal length by dropping the tail of the longer one.
atLength :: ([a] -> b) -> b -> [a] -> Int -> b Source #
atLength atLen atEnd ls n
unravels list ls
to position n
. Precisely:
atLength atLenPred atEndPred ls n | n < 0 = atLenPred ls | length ls < n = atEndPred (n - length ls) | otherwise = atLenPred (drop n ls)
lengthExceeds :: [a] -> Int -> Bool Source #
(lengthExceeds xs n) = (length xs > n)
lengthIsNot :: [a] -> Int -> Bool Source #
(lengthIsNot xs n) = (length xs /= n)
lengthAtMost :: [a] -> Int -> Bool Source #
(lengthAtMost xs n) = (length xs <= n)
lengthLessThan :: [a] -> Int -> Bool Source #
(lengthLessThan xs n) == (length xs < n)
listLengthCmp :: [a] -> Int -> Ordering Source #
equalLength :: [a] -> [b] -> Bool Source #
True if length xs == length ys
isSingleton :: [a] -> Bool Source #
Utility function to go from a singleton list to it's element.
Wether or not the argument is a singleton list is only checked in debug builds.
expectOnly :: HasCallStack => String -> [a] -> a Source #
Extract the single element of a list and panic with the given message if
there are more elements or the list was empty.
Like expectJust
, but for lists.
holes :: [a] -> [(a, [a])] Source #
Compute all the ways of removing a single element from a list.
holes [1,2,3] = [(1, [2,3]), (2, [1,3]), (3, [1,2])]
changeLast :: [a] -> a -> [a] Source #
Replace the last element of a list with another element.
mapLastM :: Functor f => (a -> f a) -> NonEmpty a -> f (NonEmpty a) Source #
Apply an effectful function to the last list element.
whenNonEmpty :: Applicative m => [a] -> (NonEmpty a -> m ()) -> m () Source #
mergeListsBy :: (a -> a -> Ordering) -> [[a]] -> [a] Source #
Merge an unsorted list of sorted lists, for example:
mergeListsBy compare [ [2,5,15], [1,10,100] ] = [1,2,5,10,15,100]
\( O(n \log{} k) \)
isSortedBy :: (a -> a -> Ordering) -> [a] -> Bool Source #
ordNubOn :: Ord b => (a -> b) -> [a] -> [a] Source #
Remove duplicates but keep elements in order. O(n * log n)
transitiveClosure :: (a -> [a]) -> (a -> a -> Bool) -> [a] -> [a] Source #
countWhile :: (a -> Bool) -> [a] -> Int Source #
splitAtList :: [b] -> [a] -> ([a], [a]) Source #
Given two lists xs and ys, return `splitAt (length xs) ys`.
onJust :: b -> Maybe a -> (a -> b) -> b Source #
onJust x m f
applies f to the value inside the Just or returns the default.
snocView :: [a] -> Maybe ([a], a) Source #
Split a list into its last element and the initial part of the list.
snocView xs = Just (init xs, last xs)
for non-empty lists.
snocView xs = Nothing
otherwise.
Unless both parts of the result are guaranteed to be used
prefer separate calls to last
+ init
.
If you are guaranteed to use both, this will
be more efficient.
capitalise :: String -> String Source #
Convert a word to title case by capitalising the first letter
removeSpaces :: String -> String Source #
fuzzyLookup :: String -> [(String, a)] -> [a] Source #
Search for possible matches to the users input in the given list, returning a small number of ranked results
strictZipWith :: (a -> b -> c) -> [a] -> [b] -> [c] Source #
strictZipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d] Source #
looksLikeModuleName :: String -> Bool Source #
looksLikePackageName :: String -> Bool Source #
readRational :: String -> Rational Source #
readSignificandExponentPair :: String -> (Integer, Integer) Source #
Parse a string into a significand and exponent. A trivial example might be: ghci> readSignificandExponentPair "1E2" (1,2) In a more complex case we might return a exponent different than that which the user wrote. This is needed in order to use a Integer significand. ghci> readSignificandExponentPair "-1.11E5" (-111,3)
readHexRational :: String -> Rational Source #
readHexSignificandExponentPair :: String -> (Integer, Integer) Source #
Parse a string into a significand and exponent according to the "Hexadecimal Floats in Haskell" proposal. A trivial example might be: ghci> readHexSignificandExponentPair "0x1p+1" (1,1) Behaves similar to readSignificandExponentPair but the base is 16 and numbers are given in hexadecimal: ghci> readHexSignificandExponentPair "0xAp-4" (10,-4) ghci> readHexSignificandExponentPair "0x1.2p3" (18,-1)
fileHashIfExists :: FilePath -> IO (Maybe Fingerprint) Source #
escapeSpaces :: String -> String Source #
abstractConstr :: String -> Constr Source #
abstractDataType :: String -> DataType Source #
hashString :: String -> Int32 Source #
A sample hash function for Strings. We keep multiplying by the golden ratio and adding. The implementation is:
hashString = foldl' f golden where f m c = fromIntegral (ord c) * magic + hashInt32 m magic = 0xdeadbeef
Where hashInt32 works just as hashInt shown above.
Knuth argues that repeated multiplication by the golden ratio will minimize gaps in the hash space, and thus it's a good choice for combining together multiple keys to form one.
Here we know that individual characters c are often small, and this produces frequent collisions if we use ord c alone. A particular problem are the shorter low ASCII and ISO-8859-1 character strings. We pre-multiply by a magic twiddle factor to obtain a good distribution. In fact, given the following test:
testp :: Int32 -> Int testp k = (n - ) . length . group . sort . map hs . take n $ ls where ls = [] : [c : l | l <- ls, c <- ['\0'..'\xff']] hs = foldl' f golden f m c = fromIntegral (ord c) * k + hashInt32 m n = 100000
We discover that testp magic = 0.
Instances
Arbitrary Value | |
CoArbitrary Value | |
Defined in Data.Aeson.Types.Internal coarbitrary :: Value -> Gen b -> Gen b | |
Function Value | |
Defined in Data.Aeson.Types.Internal | |
FromJSON Value | |
Defined in Data.Aeson.Types.FromJSON | |
ToJSON Value | |
Defined in Data.Aeson.Types.ToJSON | |
Data Value | |
Defined in Data.Aeson.Types.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Value -> c Value Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Value Source # toConstr :: Value -> Constr Source # dataTypeOf :: Value -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Value) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Value) Source # gmapT :: (forall b. Data b => b -> b) -> Value -> Value Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Value -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Value -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Value -> m Value Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Value -> m Value Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Value -> m Value Source # | |
IsString Value | |
Defined in Data.Aeson.Types.Internal fromString :: String -> Value Source # | |
Generic Value | |
Read Value | |
Show Value | |
NFData Value | |
Defined in Data.Aeson.Types.Internal | |
Quote Value | |
Unquote Value | |
Eq Value | |
Ord Value | |
Defined in Data.Aeson.Types.Internal | |
Hashable Value | |
KeyValue Encoding Series | |
Defined in Data.Aeson.Types.ToJSON (.=) :: ToJSON v => Key -> v -> Series # explicitToField :: (v -> Encoding) -> Key -> v -> Series | |
KeyValueOmit Encoding Series | |
Defined in Data.Aeson.Types.ToJSON (.?=) :: ToJSON v => Key -> v -> Series explicitToFieldOmit :: (v -> Bool) -> (v -> Encoding) -> Key -> v -> Series | |
Lift Value | |
(GToJSON' Encoding arity a, ConsToJSON Encoding arity a, Constructor c) => SumToJSON' TwoElemArray Encoding arity (C1 c a) | |
Defined in Data.Aeson.Types.ToJSON sumToJSON' :: Options -> ToArgs Encoding arity a0 -> C1 c a a0 -> Tagged TwoElemArray Encoding | |
(GToJSON' Value arity a, ConsToJSON Value arity a, Constructor c) => SumToJSON' TwoElemArray Value arity (C1 c a) | |
Defined in Data.Aeson.Types.ToJSON sumToJSON' :: Options -> ToArgs Value arity a0 -> C1 c a a0 -> Tagged TwoElemArray Value | |
GToJSON' Encoding arity (U1 :: Type -> Type) | |
Defined in Data.Aeson.Types.ToJSON | |
GToJSON' Encoding arity (V1 :: Type -> Type) | |
Defined in Data.Aeson.Types.ToJSON | |
GToJSON' Value arity (U1 :: Type -> Type) | |
Defined in Data.Aeson.Types.ToJSON | |
GToJSON' Value arity (V1 :: Type -> Type) | |
Defined in Data.Aeson.Types.ToJSON | |
ToJSON1 f => GToJSON' Encoding One (Rec1 f) | |
Defined in Data.Aeson.Types.ToJSON | |
ToJSON1 f => GToJSON' Value One (Rec1 f) | |
Defined in Data.Aeson.Types.ToJSON | |
(EncodeProduct arity a, EncodeProduct arity b) => GToJSON' Encoding arity (a :*: b) | |
Defined in Data.Aeson.Types.ToJSON | |
ToJSON a => GToJSON' Encoding arity (K1 i a :: Type -> Type) | |
Defined in Data.Aeson.Types.ToJSON | |
(WriteProduct arity a, WriteProduct arity b, ProductSize a, ProductSize b) => GToJSON' Value arity (a :*: b) | |
Defined in Data.Aeson.Types.ToJSON | |
ToJSON a => GToJSON' Value arity (K1 i a :: Type -> Type) | |
Defined in Data.Aeson.Types.ToJSON | |
(ToJSON1 f, GToJSON' Encoding One g) => GToJSON' Encoding One (f :.: g) | |
Defined in Data.Aeson.Types.ToJSON | |
(ToJSON1 f, GToJSON' Value One g) => GToJSON' Value One (f :.: g) | |
Defined in Data.Aeson.Types.ToJSON | |
FromPairs Value (DList Pair) | |
Defined in Data.Aeson.Types.ToJSON | |
value ~ Value => KeyValue Value (KeyMap value) | |
Defined in Data.Aeson.Types.ToJSON (.=) :: ToJSON v => Key -> v -> KeyMap value # explicitToField :: (v -> Value) -> Key -> v -> KeyMap value | |
value ~ Value => KeyValueOmit Value (KeyMap value) | |
Defined in Data.Aeson.Types.ToJSON (.?=) :: ToJSON v => Key -> v -> KeyMap value explicitToFieldOmit :: (v -> Bool) -> (v -> Value) -> Key -> v -> KeyMap value | |
v ~ Value => KeyValuePair v (DList Pair) | |
Defined in Data.Aeson.Types.ToJSON | |
(key ~ Key, value ~ Value) => KeyValue Value (key, value) | |
Defined in Data.Aeson.Types.ToJSON (.=) :: ToJSON v => Key -> v -> (key, value) # explicitToField :: (v -> Value) -> Key -> v -> (key, value) | |
Quote (KeyMap Value) | |
Quote (Vector Value) | |
Quote [Value] | |
Unquote (KeyMap Value) | |
Unquote (Vector Value) | |
AnsiPretty (PP Value) | |
Quote (HashMap Text Value) | |
Unquote (HashMap Text Value) | |
type Rep Value | |
Defined in Data.Aeson.Types.Internal type Rep Value = D1 ('MetaData "Value" "Data.Aeson.Types.Internal" "aeson-2.2.1.0-1MMIrk3vOVb9inhzGAxO52" 'False) ((C1 ('MetaCons "Object" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Object)) :+: (C1 ('MetaCons "Array" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Array)) :+: C1 ('MetaCons "String" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)))) :+: (C1 ('MetaCons "Number" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Scientific)) :+: (C1 ('MetaCons "Bool" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)) :+: C1 ('MetaCons "Null" 'PrefixI 'False) (U1 :: Type -> Type)))) |
Nothing
Instances
Nothing
Instances
A closed interval. The lower bound should be less than or equal to the upper bound.
Interval v v | Lower and upper bounds of the interval. |
Instances
The identity type functor.
Like Identity
, but with a shorter name.
I a |
Instances
Foldable I | |
Defined in Data.SOP.BasicFunctors fold :: Monoid m => I m -> m Source # foldMap :: Monoid m => (a -> m) -> I a -> m Source # foldMap' :: Monoid m => (a -> m) -> I a -> m Source # foldr :: (a -> b -> b) -> b -> I a -> b Source # foldr' :: (a -> b -> b) -> b -> I a -> b Source # foldl :: (b -> a -> b) -> b -> I a -> b Source # foldl' :: (b -> a -> b) -> b -> I a -> b Source # foldr1 :: (a -> a -> a) -> I a -> a Source # foldl1 :: (a -> a -> a) -> I a -> a Source # elem :: Eq a => a -> I a -> Bool Source # maximum :: Ord a => I a -> a Source # minimum :: Ord a => I a -> a Source # | |
Eq1 I | Since: sop-core-0.2.4.0 |
Ord1 I | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
Read1 I | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
Show1 I | Since: sop-core-0.2.4.0 |
Traversable I | |
Applicative I | |
Functor I | |
Monad I | |
NFData1 I | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
KnownCDF I Source # | |
FromJSON a => FromJSON (I a) Source # | |
Defined in Cardano.Util | |
ToJSON a => ToJSON (I a) Source # | |
Defined in Cardano.Util | |
Monoid a => Monoid (I a) | Since: sop-core-0.4.0.0 |
Semigroup a => Semigroup (I a) | Since: sop-core-0.4.0.0 |
Generic (I a) | |
Num (I Int) Source # | |
Read a => Read (I a) | |
Show a => Show (I a) | |
NFData a => NFData (I a) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
Eq a => Eq (I a) | |
Ord a => Ord (I a) | |
KnownCDF (CDF I) Source # | |
type Rep (I a) | |
Defined in Data.SOP.BasicFunctors |
module Data.SOP.Strict
chunksOf :: Int -> [e] -> [[e]] Source #
splits a list into length-n pieces. The last
piece will be shorter if chunksOf
nn
does not evenly divide the length of
the list. If n <= 0
,
returns an infinite list
of empty lists.chunksOf
n l
>>>
chunksOf 3 [1..12]
[[1,2,3],[4,5,6],[7,8,9],[10,11,12]]
>>>
chunksOf 3 "Hello there"
["Hel","lo ","the","re"]
>>>
chunksOf 3 ([] :: [Int])
[]
Note that
is chunksOf
n [][]
, not [[]]
. This is
intentional, and satisfies the property that
chunksOf n xs ++ chunksOf n ys == chunksOf n (xs ++ ys)
whenever n
evenly divides the length of xs
.
This is the simplest representation of UTC. It consists of the day number, and a time offset from midnight. Note that if a day has a leap second added to it, it will have 86401 seconds.
UTCTime | |
|
Instances
FromJSON UTCTime | |
Defined in Data.Aeson.Types.FromJSON | |
FromJSONKey UTCTime | |
Defined in Data.Aeson.Types.FromJSON fromJSONKey :: FromJSONKeyFunction UTCTime fromJSONKeyList :: FromJSONKeyFunction [UTCTime] | |
ToJSON UTCTime | |
Defined in Data.Aeson.Types.ToJSON | |
ToJSONKey UTCTime | |
Defined in Data.Aeson.Types.ToJSON toJSONKey :: ToJSONKeyFunction UTCTime toJSONKeyList :: ToJSONKeyFunction [UTCTime] | |
Data UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UTCTime -> c UTCTime Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UTCTime Source # toConstr :: UTCTime -> Constr Source # dataTypeOf :: UTCTime -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c UTCTime) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UTCTime) Source # gmapT :: (forall b. Data b => b -> b) -> UTCTime -> UTCTime Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UTCTime -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UTCTime -> r Source # gmapQ :: (forall d. Data d => d -> u) -> UTCTime -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> UTCTime -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime Source # | |
NFData UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime | |
Eq UTCTime | |
Ord UTCTime | |
Defined in Data.Time.Clock.Internal.UTCTime |
data NominalDiffTime Source #
This is a length of time, as measured by UTC. It has a precision of 10^-12 s.
Conversion functions such as fromInteger
and realToFrac
will treat it as seconds.
For example, (0.010 :: NominalDiffTime)
corresponds to 10 milliseconds.
It has a precision of one picosecond (= 10^-12 s). Enumeration functions will treat it as picoseconds.
It ignores leap-seconds, so it's not necessarily a fixed amount of clock time. For instance, 23:00 UTC + 2 hours of NominalDiffTime = 01:00 UTC (+ 1 day), regardless of whether a leap-second intervened.
Instances
addUTCTime :: NominalDiffTime -> UTCTime -> UTCTime Source #
addUTCTime a b = a + b
diffUTCTime :: UTCTime -> UTCTime -> NominalDiffTime Source #
diffUTCTime a b = a - b
module Data.Time.Clock.POSIX
data StrictMaybe a Source #
Instances
fromSMaybe :: a -> StrictMaybe a -> a Source #
Same as fromMaybe
(***) :: Arrow a => a b c -> a b' c' -> a (b, b') (c, c') infixr 3 Source #
Split the input between the two argument arrows and combine their output. Note that this is in general not a functor.
The default definition may be overridden with a more efficient version if desired.
(&&&) :: Arrow a => a b c -> a b c' -> a b (c, c') infixr 3 Source #
Fanout: send the input to both argument arrows and combine their output.
The default definition may be overridden with a more efficient version if desired.
(<|>) :: Alternative f => f a -> f a -> f a infixl 3 Source #
An associative binary operation
mapConcurrently :: Traversable t => (a -> IO b) -> t a -> IO (t b) Source #
Maps an IO
-performing function over any Traversable
data
type, performing all the IO
actions concurrently, and returning
the original data structure with the arguments replaced by the
results.
If any of the actions throw an exception, then all other actions are cancelled and the exception is re-thrown.
For example, mapConcurrently
works with lists:
pages <- mapConcurrently getURL ["url1", "url2", "url3"]
Take into account that async
will try to immediately spawn a thread
for each element of the Traversable
, so running this on large
inputs without care may lead to resource exhaustion (of memory,
file descriptors, or other limited resources).
forConcurrently :: Traversable t => t a -> (a -> IO b) -> IO (t b) Source #
forConcurrently
is mapConcurrently
with its arguments flipped
pages <- forConcurrently ["url1", "url2", "url3"] $ \url -> getURL url
Since: async-2.1.0
mapConcurrently_ :: Foldable f => (a -> IO b) -> f a -> IO () Source #
mapConcurrently_
is mapConcurrently
with the return value discarded;
a concurrent equivalent of mapM_
.
forConcurrently_ :: Foldable f => f a -> (a -> IO b) -> IO () Source #
forConcurrently_
is forConcurrently
with the return value discarded;
a concurrent equivalent of forM_
.
newExceptT :: m (Either x a) -> ExceptT x m a Source #
Constructor for computations in the ExceptT monad.
(The inverse of runExceptT
).
firstExceptT :: forall (m :: Type -> Type) x y a. Functor m => (x -> y) -> ExceptT x m a -> ExceptT y m a Source #
Map the Left
unwrapped computation using the given function.
printf :: PrintfType r => String -> r Source #
Format a variable number of arguments with the C-style formatting string.
>>>
printf "%s, %d, %.4f" "hello" 123 pi
hello, 123, 3.1416
The return value is either String
or (
(which
should be IO
a)(
, but Haskell's type system
makes this hard).IO
())
The format string consists of ordinary characters and
conversion specifications, which specify how to format
one of the arguments to printf
in the output string. A
format specification is introduced by the %
character;
this character can be self-escaped into the format string
using %%
. A format specification ends with a
format character that provides the primary information about
how to format the value. The rest of the conversion
specification is optional. In order, one may have flag
characters, a width specifier, a precision specifier, and
type-specific modifier characters.
Unlike C printf(3)
, the formatting of this printf
is driven by the argument type; formatting is type specific. The
types formatted by printf
"out of the box" are:
printf
is also extensible to support other types: see below.
A conversion specification begins with the
character %
, followed by zero or more of the following flags:
- left adjust (default is right adjust) + always use a sign (+ or -) for signed conversions space leading space for positive numbers in signed conversions 0 pad with zeros rather than spaces # use an \"alternate form\": see below
When both flags are given, -
overrides 0
and +
overrides space.
A negative width specifier in a *
conversion is treated as
positive but implies the left adjust flag.
The "alternate form" for unsigned radix conversions is
as in C printf(3)
:
%o prefix with a leading 0 if needed %x prefix with a leading 0x if nonzero %X prefix with a leading 0X if nonzero %b prefix with a leading 0b if nonzero %[eEfFgG] ensure that the number contains a decimal point
Any flags are followed optionally by a field width:
num field width * as num, but taken from argument list
The field width is a minimum, not a maximum: it will be expanded as needed to avoid mutilating a value.
Any field width is followed optionally by a precision:
.num precision . same as .0 .* as num, but taken from argument list
Negative precision is taken as 0. The meaning of the precision depends on the conversion type.
Integral minimum number of digits to show RealFloat number of digits after the decimal point String maximum number of characters
The precision for Integral types is accomplished by zero-padding. If both precision and zero-pad are given for an Integral field, the zero-pad is ignored.
Any precision is followed optionally for Integral types by a width modifier; the only use of this modifier being to set the implicit size of the operand for conversion of a negative operand to unsigned:
hh Int8 h Int16 l Int32 ll Int64 L Int64
The specification ends with a format character:
c character Integral d decimal Integral o octal Integral x hexadecimal Integral X hexadecimal Integral b binary Integral u unsigned decimal Integral f floating point RealFloat F floating point RealFloat g general format float RealFloat G general format float RealFloat e exponent format float RealFloat E exponent format float RealFloat s string String v default format any type
The "%v" specifier is provided for all built-in types, and should be provided for user-defined type formatters as well. It picks a "best" representation for the given type. For the built-in types the "%v" specifier is converted as follows:
c Char u other unsigned Integral d other signed Integral g RealFloat s String
Mismatch between the argument types and the format string, as well as any other syntactic or semantic errors in the format string, will cause an exception to be thrown at runtime.
Note that the formatting for RealFloat
types is
currently a bit different from that of C printf(3)
,
conforming instead to showEFloat
,
showFFloat
and showGFloat
(and their
alternate versions showFFloatAlt
and
showGFloatAlt
). This is hard to fix: the fixed
versions would format in a backward-incompatible way.
In any case the Haskell behavior is generally more
sensible than the C behavior. A brief summary of some
key differences:
- Haskell
printf
never uses the default "6-digit" precision used by C printf. - Haskell
printf
treats the "precision" specifier as indicating the number of digits after the decimal point. - Haskell
printf
prints the exponent of e-format numbers without a gratuitous plus sign, and with the minimum possible number of digits. - Haskell
printf
will place a zero after a decimal point when possible.
type SMaybe a = StrictMaybe a Source #
Instances
FromJSON RUTCTime Source # | |
Defined in Cardano.Util | |
ToJSON RUTCTime Source # | |
Defined in Cardano.Util | |
Num RUTCTime Source # | |
Defined in Cardano.Util (+) :: RUTCTime -> RUTCTime -> RUTCTime Source # (-) :: RUTCTime -> RUTCTime -> RUTCTime Source # (*) :: RUTCTime -> RUTCTime -> RUTCTime Source # negate :: RUTCTime -> RUTCTime Source # abs :: RUTCTime -> RUTCTime Source # signum :: RUTCTime -> RUTCTime Source # fromInteger :: Integer -> RUTCTime Source # | |
Real RUTCTime Source # | |
Defined in Cardano.Util toRational :: RUTCTime -> Rational Source # | |
Show RUTCTime Source # | |
NFData RUTCTime Source # | |
Defined in Cardano.Util | |
Eq RUTCTime Source # | |
Ord RUTCTime Source # | |
Defined in Cardano.Util | |
Divisible RUTCTime Source # | |
isSNothing :: SMaybe a -> Bool Source #
strictMaybe :: Maybe a -> SMaybe a Source #
smaybe :: b -> (a -> b) -> StrictMaybe a -> b Source #
lazySMaybe :: SMaybe a -> Maybe a Source #
catSMaybes :: [SMaybe a] -> [a] Source #
mapSMaybe :: (a -> StrictMaybe b) -> [a] -> [b] Source #
mapSMaybeFB :: (b -> r -> r) -> (a -> StrictMaybe b) -> a -> r -> r Source #
mapConcurrentlyPure :: NFData b => (a -> b) -> [a] -> IO [b] Source #
redistribute :: (a, (b, c)) -> ((a, b), (a, c)) Source #
norm2Tuple :: ((a, b), c) -> (a, (b, c)) Source #
roundUTCTimeSec :: UTCTime -> UTCTime Source #
roundUTCTimeDay :: UTCTime -> UTCTime Source #
zeroUTCTime :: UTCTime Source #
A tweaked version of UTCTime that is able to have more instances. Structurally equivalent to difftime from zeroUTCTime
toRUTCTime :: UTCTime -> RUTCTime Source #
fromRUTCTime :: RUTCTime -> UTCTime Source #