### Aeson unsafePairSBS Example Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-Encoding-Internal Demonstrates the usage of `unsafePairSBS` for encoding a key-value pair where the key is a pre-encoded ShortByteString, including quotes and a colon. ```Haskell pair "foo" v = unsafePairSBS ("\"foo\":") v ``` -------------------------------- ### Derive JSON instances for tuples Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-TH This example demonstrates how to derive JSON instances for tuples, specifically 4-tuples, using a concise syntax with `deriveJSON` and the tuple constructor. ```Haskell $(deriveJSON defaultOptions ''(,,,)) ``` -------------------------------- ### Haskell KeyMap: Basic Operations Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides essential functions for working with KeyMap, including checking for emptiness, looking up values, getting the size, and checking for key membership. ```Haskell null :: KeyMap v -> Bool lookup :: Key -> KeyMap v -> Maybe v (!?) :: KeyMap v -> Key -> Maybe v size :: KeyMap v -> Int member :: Key -> KeyMap a -> Bool ``` -------------------------------- ### Get Keys from KeyMap (Haskell) Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Returns a list of all keys present in the KeyMap. ```Haskell keys :: KeyMap v -> [Key] ``` -------------------------------- ### Example usage of derived JSON instances Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-TH This example shows how to use the previously derived JSON instances for the 'D' data type. It creates an instance of 'D Int' and then verifies that encoding it to JSON and then decoding it back results in the original data structure. ```Haskell d :: D Int d = Record { testOne = 3.14159 , testTwo = True , testThree = Product "test" 'A' 123 } fromJSON (toJSON d) == Success d ``` -------------------------------- ### Haskell KeyMap: Construction Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Demonstrates how to create and populate KeyMap instances, including creating empty maps, singleton maps, and inserting key-value pairs, with options for handling duplicate keys. ```Haskell empty :: KeyMap v singleton :: Key -> v -> KeyMap v insert :: Key -> v -> KeyMap v -> KeyMap v insertWith :: (a -> a -> a) -> Key -> a -> KeyMap a -> KeyMap a ``` -------------------------------- ### Haskell: Unescape Text IO Function Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/src/Data.Aeson.Internal The main IO function for unescaping text. It takes a Text source, a starting offset, and a length, then initializes the unescaping process by creating a mutable array and starting the state machine. ```Haskell unescapeFromTextIO (Text src begin len) = do let end :: Offset end = begin + len arr <- P.newPrimArray len ``` -------------------------------- ### Aeson KeyMap Read and Show Instances Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Defines `Read` and `Show` instances for `KeyMap`, enabling parsing from and rendering to string representations. `readsPrec` and `readPrec` handle parsing, while `showsPrec` and `show` manage string conversion for `KeyMap` data. ```Haskell Read v => Read (KeyMap v) readsPrec :: Int -> ReadS (KeyMap v) readList :: ReadS [KeyMap v] readPrec :: ReadPrec (KeyMap v) readListPrec :: ReadPrec [KeyMap v] Show v => Show (KeyMap v) showsPrec :: Int -> KeyMap v -> ShowS show :: KeyMap v -> String showList :: [KeyMap v] -> ShowS ``` -------------------------------- ### Zip Instance for KeyMap Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides a Zip instance for KeyMap, allowing for zipping operations on two KeyMaps. Includes zip and zipWith. ```Haskell zip :: KeyMap a -> KeyMap b -> KeyMap (a, b) zipWith :: (a -> b -> c) -> KeyMap a -> KeyMap b -> KeyMap c ``` -------------------------------- ### Aeson: Search Functionality Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/doc-index-I Provides keyboard shortcuts for navigating and searching within the Aeson package documentation. Users can open a search box, close it, and move through search results using arrow keys or Ctrl+J/Ctrl+K. ```text Key| Shortcut ---|--- s| Open this search box esc| Close this search box ↓,ctrl + j| Move down in search results ↑,ctrl + k| Move up in search results ↵| Go to active search result ``` -------------------------------- ### Haskell KeyMap: HashMap Conversions Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Demonstrates conversions between KeyMap and HashMap, including specialized versions for HashMap with Text keys. ```Haskell fromHashMap :: HashMap Key v -> KeyMap v toHashMap :: KeyMap v -> HashMap Key v fromHashMapText :: HashMap Text v -> KeyMap v toHashMapText :: KeyMap v -> HashMap Text v coercionToHashMap :: Maybe (Coercion (HashMap Key v) (KeyMap v)) ``` -------------------------------- ### Clone Aeson Git Repository Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/package/aeson Provides the command to clone the Aeson package's master Git repository, allowing users to access the source code. ```bash git clone git://github.com/haskell/aeson.git ``` -------------------------------- ### Strip Prefix from ByteString Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/src/Data.Aeson.Decoding.ByteString A utility function to check if a ByteString starts with a given prefix and, if so, return the ByteString with the prefix removed. It's used for efficient string manipulation. ```Haskell stripPrefix :: ByteString -> Int -> ByteString -> Maybe ByteString stripPrefix pfx n bs | LBS.isPrefixOf pfx bs = Just (LBS.drop (fromIntegral n) bs) | otherwise = Nothing ``` -------------------------------- ### KeyMap Construction Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Functions for creating new KeyMap instances. This includes creating an empty map, a map with a single key-value pair, and constructing maps from lists with options for handling duplicate keys. ```Haskell empty :: KeyMap v singleton :: Key -> v -> KeyMap v fromList :: [(Key, v)] -> KeyMap v fromListWith :: (v -> v -> v) -> [(Key, v)] -> KeyMap v ``` -------------------------------- ### Parse 8 Nested Chars to BoundedPrim (Haskell) Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/src/Data.Aeson.Encoding This snippet shows the parsing of an 8-character nested tuple into a BoundedPrim type. It represents the most deeply nested structure among the provided examples, utilizing `BP.char7` for each character. ```Haskell ascii8 :: (Char, (Char, (Char, (Char, (Char, (Char, (Char, Char))))))) -> BP.BoundedPrim a ascii8 (Char, (Char, (Char, (Char, (Char, (Char, (Char, Char))))))) cs = FixedPrim a -> BoundedPrim a BP.liftFixedToBounded (FixedPrim a -> BoundedPrim a) -> FixedPrim a -> BoundedPrim a $ (Char, (Char, (Char, (Char, (Char, (Char, (Char, Char))))))) -> a -> (Char, (Char, (Char, (Char, (Char, (Char, (Char, Char))))))) ``` -------------------------------- ### Aeson Package Index - Haskell Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/doc-index-U This section lists various functions and types available in the Aeson package, categorized by their module. It aids in quickly finding specific functionalities for JSON parsing and encoding. ```Haskell unescapeText| Data.Aeson.Decoding unexpected| Data.Aeson.Types union| Data.Aeson.KeyMap unionWith| Data.Aeson.KeyMap unionWithKey| Data.Aeson.KeyMap unsafePairSBS| Data.Aeson.Encoding.Internal unsafeToEncoding| Data.Aeson.Encoding.Internal, Data.Aeson.Encoding, Data.Aeson.Types UntaggedValue| Data.Aeson.Types, Data.Aeson, Data.Aeson.TH unwrapUnaryRecords| Data.Aeson.Types, Data.Aeson, Data.Aeson.TH utcTime| Data.Aeson.Encoding.Internal, Data.Aeson.Encoding ``` -------------------------------- ### Encoding JSON Numbers (Double) Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-Encoding-Internal Demonstrates encoding Double-precision floating-point numbers into JSON using the `double` constructor. It shows examples for standard numbers, NaN, positive infinity, and negative infinity. ```Haskell double :: Double -> Encoding Source # >>> double 42 **"42.0" >>> double (0/0) **"null" >>> double (1/0) **"+inf" >>> double (-23/0) **"-inf" ``` -------------------------------- ### QQ Syntax for Aeson Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/doc-index-All QuasiQuoter functions for convenient JSON construction and parsing within Haskell code. ```Haskell aesonQQ :: QuasiQuoter ``` -------------------------------- ### Direct Encoding with genericToEncoding Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/src/Data Provides an example of implementing direct JSON encoding for a custom data type using 'genericToEncoding' and GHC's 'Generic' class. This is an efficient method for encoding. ```Haskell -- @ -- 'toEncoding' = 'genericToEncoding' 'defaultOptions' -- @ ``` -------------------------------- ### Haskell: Decoding Lists and Maps Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/src/Data Provides examples of decoding common Haskell data structures like lists of integers and 'Map' from JSON strings. It demonstrates the flexibility of Aeson in handling various types. ```Haskell -- > >>> decode "[1,2,3]" :: Maybe [Int] -- > Just [1,2,3] -- -- > >>> decode "{\"foo\":1,\"bar\":2}" :: Maybe (Map String Int) -- > Just (fromList [("bar",2),("foo",1)]) ``` -------------------------------- ### Fold Left over KeyMap (Haskell) Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Reduces a KeyMap by applying a binary operator from left to right, using a starting value. The operator takes the accumulated value of type 'b' and an element of type 'a', returning a new accumulated value of type 'b'. ```Haskell foldl :: (b -> a -> b) -> b -> KeyMap a -> b ``` -------------------------------- ### Haskell KeyMap: Map Conversions Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Illustrates conversions between KeyMap and standard Map structures, including versions for Map with Text keys. ```Haskell fromMap :: Map Key v -> KeyMap v toSparseMap :: KeyMap v -> Map Key v fromMapText :: Map Text v -> KeyMap v toSparseMapText :: KeyMap v -> Map Text v coercionToMap :: Maybe (Coercion (Map Key v) (KeyMap v)) ``` -------------------------------- ### Fold Right over KeyMap (Haskell) Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Reduces a KeyMap by applying a binary operator from right to left, using a starting value. The operator takes an element of type 'a' and the accumulated value of type 'b', returning a new accumulated value of type 'b'. ```Haskell foldr :: (a -> b -> b) -> b -> KeyMap a -> b ``` -------------------------------- ### ZipWithIndex Instance for KeyMap Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Defines a ZipWithIndex instance for KeyMap, enabling key-aware zipping operations. Includes izipWith. ```Haskell izipWith :: (Key -> a -> b -> c) -> KeyMap a -> KeyMap b -> KeyMap c ``` -------------------------------- ### Fold Right with Key over KeyMap (Haskell) Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Reduces this map by applying a binary operator to all elements, using the given starting value. The operator takes a Key, a value of type 'v', and the accumulated value of type 'a', returning a new accumulated value of type 'a'. ```Haskell foldrWithKey :: (Key -> v -> a -> a) -> a -> KeyMap v -> a ``` -------------------------------- ### Haskell Read and Show instances for Key Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides Read and Show instances for Key, allowing Key values to be parsed from strings and converted to strings, respectively. This is useful for debugging and serialization. ```Haskell readsPrec :: Int -> ReadS Key readList :: ReadS [Key] readPrec :: ReadPrec Key readListPrec :: ReadPrec [Key] ``` ```Haskell showsPrec :: Int -> Key -> ShowS show :: Key -> String showList :: [Key] -> ShowS ``` -------------------------------- ### Haskell: Unescape Text State Machine Start Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/src/Data.Aeson.Internal Initializes the text unescaping state machine. It takes input and output offsets and returns an IO Text action. The function handles the initial state and transitions based on input characters. ```Haskell state_start (Offset 0 :: Int) Offset begin ``` -------------------------------- ### Haskell ZipWithIndex instance for KeyMap Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides the ZipWithIndex instance for KeyMap, enabling element-wise zipping of two KeyMaps where the zipping function receives the key. ```Haskell izipWith :: (Key -> a -> b -> c) -> KeyMap a -> KeyMap b -> KeyMap c ``` -------------------------------- ### Encoding Double Precision Floating-Point Numbers Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-Encoding Demonstrates how to encode Double precision floating-point numbers using the `double` function. It shows examples for standard numbers, NaN, positive infinity, and negative infinity, illustrating how these special values are represented in JSON. ```Haskell double 42 **"42.0" ``` ```Haskell double (0/0) **"null" ``` ```Haskell double (1/0) **"+inf" ``` ```Haskell double (-23/0) **"-inf" ``` -------------------------------- ### Compile-time JSON to Value Conversion (Haskell) Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-QQ-Simple Demonstrates the usage of the `aesonQQ` QuasiQuoter to convert a JSON string into a Haskell `Value` at compile time. This requires the `QuasiQuotes` language extension and imports `Value` from `Data.Aeson` and `aesonQQ` from `Data.Aeson.QQ.Simple`. ```Haskell {-# LANGUAGE QuasiQuotes #} import Data.Aeson (Value) import Data.Aeson.QQ.Simple joe :: Value joe = [aesonQQ|{ "name": "Joe", "age": 12 }|] ``` -------------------------------- ### Haskell KeyMap: List Conversions Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Shows how to convert KeyMap instances to and from lists of key-value pairs, including ordered and unordered representations. ```Haskell fromList :: [(Key, v)] -> KeyMap v fromListWith :: (v -> v -> v) -> [(Key, v)] -> KeyMap v toSparseList :: KeyMap v -> [(Key, v)] toAscList :: KeyMap v -> [(Key, v)] ``` -------------------------------- ### Haskell: Working with JSON AST (Value) Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/src/Data Demonstrates using the 'Value' type to represent arbitrary JSON data, allowing for direct manipulation without defining custom data types. Examples include decoding JSON objects and arrays into 'Value'. ```Haskell -- > >>> decode "{\"foo\": 123}" :: Maybe Value -- > Just (Object (fromList [("foo",Number 123)])) -- -- > >>> decode "{\"foo\": [\"abc\",\"def\"]}" :: Maybe Value -- > Just (Object (fromList [("foo",Array (fromList [String "abc",String "def"])]))) -- -- Once you have a 'Value' you can write functions to traverse it and -- make arbitrary transformations. ``` -------------------------------- ### Functor Instance for KeyMap Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides a Functor instance for KeyMap, enabling the application of a function to each element within the KeyMap. Includes fmap and <$. ```Haskell fmap :: (a -> b) -> KeyMap a -> KeyMap b (<$) :: a -> KeyMap b -> KeyMap a ``` -------------------------------- ### Align Instance for KeyMap Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Defines an Align instance for KeyMap, supporting alignment operations. It includes the 'nil' constructor for creating an empty KeyMap. ```Haskell nil :: KeyMap a ``` -------------------------------- ### Haskell Read and Show instances for Key Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-Key Provides Read and Show instances for Key, allowing Key values to be parsed from strings and converted to strings, respectively. This is useful for debugging and serialization. ```Haskell readsPrec :: Int -> ReadS Key readList :: ReadS [Key] readPrec :: ReadPrec Key readListPrec :: ReadPrec [Key] ``` ```Haskell showsPrec :: Int -> Key -> ShowS show :: Key -> String showList :: [Key] -> ShowS ``` -------------------------------- ### Show (TkRecord k e) Instance Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-Decoding-Tokens Defines how to convert a TkRecord to a String for display, requiring the key and element types to also be Showable. Includes showsPrec, show, and showList. ```Haskell showsPrec :: Int -> TkRecord k e -> ShowS show :: TkRecord k e -> String showList :: [TkRecord k e] -> ShowS ``` -------------------------------- ### Arbitrary Instance for KeyMap Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides an Arbitrary instance for KeyMap, allowing for the generation of random KeyMap values for testing purposes. It requires a Gen a to generate the values within the KeyMap. ```Haskell liftArbitrary :: Gen a -> Gen (KeyMap a) liftShrink :: (a -> [a]) -> KeyMap a -> [KeyMap a] ``` -------------------------------- ### Aeson KeyMap CoArbitrary and Function Instances Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Introduces `CoArbitrary` and `Function` instances for `KeyMap`, facilitating advanced testing and functional programming patterns. `coarbitrary` aids in generating test data, while `function` allows mapping functions over `KeyMap` structures. ```Haskell CoArbitrary v => CoArbitrary (KeyMap v) coarbitrary :: KeyMap v -> Gen b -> Gen b Function v => Function (KeyMap v) function :: (KeyMap v -> b) -> KeyMap v :-> b ``` -------------------------------- ### Aeson KeyMap Construction with KeyValue Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Demonstrates constructing a singleton `KeyMap` using `KeyValue`. This is useful for functions expecting an `Object` type, especially when combined with `mconcat`. The `object` function is generally preferred for creating objects. ```Haskell value ~ Value => KeyValue Value (KeyMap value) -- Constructs a singleton `KeyMap`. For calling functions that demand an `Object` for constructing objects. To be used in conjunction with `mconcat`. Prefer to use `object` where possible. ``` -------------------------------- ### Semialign Instance for KeyMap Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Implements a Semialign instance for KeyMap, providing functions for aligning KeyMaps based on their keys. Includes align and alignWith. ```Haskell align :: KeyMap a -> KeyMap b -> KeyMap (These a b) alignWith :: (These a b -> c) -> KeyMap a -> KeyMap b -> KeyMap c ``` -------------------------------- ### Aeson KeyMap Data and Generic Programming Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides instances for the `Data` type class, enabling generic programming techniques for `KeyMap`. Methods like `gfoldl`, `gunfold`, and `gmapT` allow for structural manipulation and traversal of `KeyMap` data. ```Haskell Data v => Data (KeyMap v) gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> KeyMap v -> c (KeyMap v) gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (KeyMap v) toConstr :: KeyMap v -> Constr dataTypeOf :: KeyMap v -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (KeyMap v)) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (KeyMap v)) gmapT :: (forall b. Data b => b -> b) -> KeyMap v -> KeyMap v gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> KeyMap v -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> KeyMap v -> r gmapQ :: (forall d. Data d => d -> u) -> KeyMap v -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> KeyMap v -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> KeyMap v -> m (KeyMap v) gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> KeyMap v -> m (KeyMap v) gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> KeyMap v -> m (KeyMap v) ``` -------------------------------- ### JSON Key Options and Defaults in Aeson Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/doc-index-D This snippet covers functions for defining default options for JSON key mapping and deriving JSON instances. It includes functions for setting key options and deriving instances for custom data types. ```Haskell defaultJSONKeyOptions :: JSONKeyOptions defaultOptions :: Options defaultTaggedObject :: TaggedObject a ``` -------------------------------- ### Aeson KeyMap Arbitrary Instance for Testing Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Defines an `Arbitrary` instance for `KeyMap`, allowing the generation of random `KeyMap` values for testing purposes. This instance, available since version 2.0.3.0, includes methods for generating and shrinking `KeyMap` data. ```Haskell Arbitrary v => Arbitrary (KeyMap v) arbitrary :: Gen (KeyMap v) shrink :: KeyMap v -> [KeyMap v] ``` -------------------------------- ### Haskell ZipWithIndex instance for KeyMap Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-Key Provides the ZipWithIndex instance for KeyMap, enabling element-wise zipping of two KeyMaps where the zipping function receives the key. ```Haskell izipWith :: (Key -> a -> b -> c) -> KeyMap a -> KeyMap b -> KeyMap c ``` -------------------------------- ### Aeson Encoding Instances (IsString, Show, Eq, Ord) Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-Encoding Provides instances for Encoding' related types, including IsString for string conversion, Show for representation, Eq for equality comparison, and Ord for ordering. ```Haskell IsString (Encoding' a) Source #| _Since: 2.2.0.0_ Instance detailsDefined in Data.Aeson.Encoding.Internal MethodsfromString :: String -> Encoding' a # Show (Encoding' a) Source #| Instance detailsDefined in Data.Aeson.Encoding.Internal MethodsshowsPrec :: Int -> Encoding' a -> ShowS #show :: Encoding' a -> String #showList :: [Encoding' a] -> ShowS # Eq (Encoding' a) Source #| Instance detailsDefined in Data.Aeson.Encoding.Internal Methods(==) :: Encoding' a -> Encoding' a -> Bool #(/=) :: Encoding' a -> Encoding' a -> Bool # Ord (Encoding' a) Source #| Instance detailsDefined in Data.Aeson.Encoding.Internal Methodscompare :: Encoding' a -> Encoding' a -> Ordering #(<) :: Encoding' a -> Encoding' a -> Bool #(<=) :: Encoding' a -> Encoding' a -> Bool #(>) :: Encoding' a -> Encoding' a -> Bool #(>=) :: Encoding' a -> Encoding' a -> Bool #max :: Encoding' a -> Encoding' a -> Encoding' a #min :: Encoding' a -> Encoding' a -> Encoding' a # ``` -------------------------------- ### Haskell IsString instance for Key Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides the IsString instance for Key, allowing Key values to be created directly from string literals using the OverloadedStrings extension. ```Haskell fromString :: String -> Key ``` -------------------------------- ### SemialignWithIndex Instance for KeyMap Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides a SemialignWithIndex instance for KeyMap, supporting key-aware alignment operations. Includes ialignWith. ```Haskell ialignWith :: (Key -> These a b -> c) -> KeyMap a -> KeyMap b -> KeyMap c ``` -------------------------------- ### Haskell FromJSONKey and ToJSONKey instances Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides instances for FromJSONKey and ToJSONKey, which are used for custom JSON key handling. These allow specifying how keys are serialized and deserialized in JSON objects. ```Haskell fromJSONKey :: FromJSONKeyFunction Key fromJSONKeyList :: FromJSONKeyFunction [Key] ``` ```Haskell toJSONKey :: ToJSONKeyFunction Key toSJONKeyList :: ToJSONKeyFunction [Key] ``` -------------------------------- ### Haskell Eq and Ord instances for Key Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides Eq and Ord instances for Key, enabling equality comparisons and ordering of Key values. This is fundamental for using Key in data structures and algorithms. ```Haskell (==) :: Key -> Key -> Bool (/=) :: Key -> Key -> Bool ``` ```Haskell compare :: Key -> Key -> Ordering (<) :: Key -> Key -> Bool (<=) :: Key -> Key -> Bool (>) :: Key -> Key -> Bool (>=) :: Key -> Key -> Bool max :: Key -> Key -> Key min :: Key -> Key -> Key ``` -------------------------------- ### Aeson Encoding Instances Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-Encoding-Internal Details the instances for the Encoding type in Aeson, including IsString, Show, Eq, and Ord. These instances define how Encoding values can be treated as strings, displayed, compared for equality, and ordered. ```Haskell instance IsString (Encoding' a) -- _Since: 2.2.0.0_ instance Show (Encoding' a) instance Eq (Encoding' a) instance Ord (Encoding' a) ``` -------------------------------- ### Haskell FromJSONKey and ToJSONKey instances Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-Key Provides instances for FromJSONKey and ToJSONKey, which are used for custom JSON key handling. These allow specifying how keys are serialized and deserialized in JSON objects. ```Haskell fromJSONKey :: FromJSONKeyFunction Key fromJSONKeyList :: FromJSONKeyFunction [Key] ``` ```Haskell toJSONKey :: ToJSONKeyFunction Key toSJONKeyList :: ToJSONKeyFunction [Key] ``` -------------------------------- ### FoldableWithIndex Instance for KeyMap Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides a FoldableWithIndex instance for KeyMap, allowing folding operations that consider the keys. Includes ifoldMap, ifoldr, and ifoldl. ```Haskell ifoldMap :: Monoid m => (Key -> a -> m) -> KeyMap a -> m ifoldMap' :: Monoid m => (Key -> a -> m) -> KeyMap a -> m ifoldr :: (Key -> a -> b -> b) -> b -> KeyMap a -> b ifoldl :: (Key -> b -> a -> b) -> b -> KeyMap a -> b ifoldr' :: (Key -> a -> b -> b) -> b -> KeyMap a -> b ifoldl' :: (Key -> b -> a -> b) -> b -> KeyMap a -> b ``` -------------------------------- ### Haskell IsString instance for Key Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-Key Provides the IsString instance for Key, allowing Key values to be created directly from string literals using the OverloadedStrings extension. ```Haskell fromString :: String -> Key ``` -------------------------------- ### Haskell Data instance for Key Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Defines the Data instance for the Key type, enabling generic programming capabilities. This allows functions that operate on Data types to work with Key. ```Haskell gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Key -> c Key gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Key toConstr :: Key -> Constr dataTypeOf :: Key -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Key) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Key) gmapT :: (forall b. Data b => b -> b) -> Key -> Key gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r gmapQ :: (forall d. Data d => d -> u) -> Key -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Key -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Key -> m Key gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Key -> m Key gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Key -> m Key ``` -------------------------------- ### Creating Aeson KeyMap from Lists and Maps Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/doc-index-All Functions to construct Aeson KeyMaps from lists of key-value pairs or standard Haskell Maps. This facilitates the conversion of common data structures to Aeson's KeyMap. ```Haskell fromList :: (FromJSONKey k, FromJSON v) => [(Text, v)] -> KeyMap k v fromListWith :: (FromJSONKey k, FromJSON v) => (v -> v -> v) -> [(Text, v)] -> KeyMap k v fromMap :: (FromJSONKey k, FromJSON v) => Map Text v -> KeyMap k v fromMapText :: (FromJSONKey k, FromJSON v) => Map Text Text -> KeyMap k v ``` -------------------------------- ### Aeson Encoding Utilities Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/doc-index-E Contains internal and utility functions for JSON encoding, including creating empty JSON arrays and objects, and managing encoding state. ```Haskell econcat :: Encoding -> Encoding Empty :: Encoding emptyArray :: Encoding emptyArray_ :: Encoding emptyObject :: Encoding emptyObject_ :: Encoding Encoding' :: Encoding -> Encoding encodingToLazyByteString :: Encoding -> ByteString ``` -------------------------------- ### KeyMap Comparison Methods Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides methods for comparing two KeyMap structures. These include equality checks (<, <=, >, >=), and finding the maximum and minimum KeyMaps based on their contents. ```Haskell compare :: KeyMap v -> KeyMap v -> Ordering (<) :: KeyMap v -> KeyMap v -> Bool (<=) :: KeyMap v -> KeyMap v -> Bool (>) :: KeyMap v -> KeyMap v -> Bool (>=) :: KeyMap v -> KeyMap v -> Bool max :: KeyMap v -> KeyMap v -> KeyMap v min :: KeyMap v -> KeyMap v -> KeyMap v ``` -------------------------------- ### Aeson KeyMap Lifting and Code Generation Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides functionality for lifting `KeyMap` into different type contexts for code generation. `lift` and `liftTyped` are used to generate `Exp` or `Code m (KeyMap v)` respectively, enabling programmatic construction of `KeyMap` representations. ```Haskell lift :: Quote m => KeyMap v -> m Exp liftTyped :: forall (m :: Type -> Type). Quote m => KeyMap v -> Code m (KeyMap v) ``` -------------------------------- ### Aeson KeyMap Monoid and Semigroup Operations Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Defines `Monoid` and `Semigroup` instances for `KeyMap`, enabling combination and aggregation of key-value maps. `mempty` provides an empty map, `mappend` and `<>` combine maps, and `mconcat` aggregates a list of maps. ```Haskell Monoid (KeyMap v) mempty :: KeyMap v mappend :: KeyMap v -> KeyMap v -> KeyMap v mconcat :: [KeyMap v] -> KeyMap v Semigroup (KeyMap v) (<>) :: KeyMap v -> KeyMap v -> KeyMap v sconcat :: NonEmpty (KeyMap v) -> KeyMap v stimes :: Integral b => b -> KeyMap v -> KeyMap v ``` -------------------------------- ### Haskell FromJSON and ToJSON instances for Key Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Defines instances for FromJSON and ToJSON for the Key type, enabling conversion between JSON values and Key. This includes parsing and encoding Key values. ```Haskell parseJSON :: Value -> Parser Key parseJSONList :: Value -> Parser [Key] omittedField :: Maybe Key ``` ```Haskell toJSON :: Key -> Value toEncoding :: Key -> Encoding toSJONList :: [Key] -> Value toEncodingList :: [Key] -> Encoding omitField :: Key -> Bool ``` -------------------------------- ### TkArray Show Instance Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-Decoding-Tokens Provides a string representation for TkArray, requiring Show constraints on key and element types. ```Haskell showsPrec :: Int -> TkArray k e -> ShowS show :: TkArray k e -> String showList :: [TkArray k e] -> ShowS ``` -------------------------------- ### Aeson: FromArgs and Time Conversion Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/doc-index-F The `FromArgs` typeclass and `fromDotNetTime` function are provided for parsing arguments and converting .NET time formats, available in `Data.Aeson.Types` and `Data.Aeson`. ```Haskell FromArgs fromDotNetTime ``` -------------------------------- ### Aeson KeyMap Eq and Ord Instances Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Defines `Eq` and `Ord` instances for `KeyMap`, enabling equality comparison and ordering of key-value maps. `(==)` and `(/=)` check for equality, while the `Ord` instance provides comparison operators based on the keys and values. ```Haskell Eq v => Eq (KeyMap v) (==) :: KeyMap v -> KeyMap v -> Bool (/=) :: KeyMap v -> KeyMap v -> Bool Ord v => Ord (KeyMap v) ``` -------------------------------- ### Haskell Eq and Ord instances for Key Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-Key Provides Eq and Ord instances for Key, enabling equality comparisons and ordering of Key values. This is fundamental for using Key in data structures and algorithms. ```Haskell (==) :: Key -> Key -> Bool (/=) :: Key -> Key -> Bool ``` ```Haskell compare :: Key -> Key -> Ordering (<) :: Key -> Key -> Bool (<=) :: Key -> Key -> Bool (>) :: Key -> Key -> Bool (>=) :: Key -> Key -> Bool max :: Key -> Key -> Key min :: Key -> Key -> Key ``` -------------------------------- ### Haskell KeyMap: Combination Operations Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Explains how to combine multiple KeyMap structures, including taking differences, unions, and intersections, with options for custom merging logic. ```Haskell difference :: KeyMap v -> KeyMap v' -> KeyMap v union :: KeyMap v -> KeyMap v -> KeyMap v unionWith :: (v -> v -> v) -> KeyMap v -> KeyMap v -> KeyMap v unionWithKey :: (Key -> v -> v -> v) -> KeyMap v -> KeyMap v -> KeyMap v intersection :: KeyMap a -> KeyMap b -> KeyMap a intersectionWith :: (a -> b -> c) -> KeyMap a -> KeyMap b -> KeyMap c intersectionWithKey :: (Key -> a -> b -> c) -> KeyMap a -> KeyMap b -> KeyMap c ``` -------------------------------- ### Aeson KeyMap NFData Instance Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides an `NFData` instance for `KeyMap`, allowing for strict evaluation and normalization of `KeyMap` data structures. The `rnf` method ensures that all components of the `KeyMap` are fully evaluated. ```Haskell NFData v => NFData (KeyMap v) yalnızca :: KeyMap v -> () ``` -------------------------------- ### Aeson: TH for Constructor and Content Fields Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/doc-index-C This snippet includes functions related to Template Haskell (TH) for defining JSON constructors and content fields. These are useful for deriving instances and customizing JSON field names. ```Haskell constructorTagModifier| Data.Aeson.Types, Data.Aeson, Data.Aeson.TH contentsFieldName| Data.Aeson.Types, Data.Aeson, Data.Aeson.TH ``` -------------------------------- ### Haskell FromJSON and ToJSON instances for Key Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-Key Defines instances for FromJSON and ToJSON for the Key type, enabling conversion between JSON values and Key. This includes parsing and encoding Key values. ```Haskell parseJSON :: Value -> Parser Key parseJSONList :: Value -> Parser [Key] omittedField :: Maybe Key ``` ```Haskell toJSON :: Key -> Value toEncoding :: Key -> Encoding toSJONList :: [Key] -> Value toEncodingList :: [Key] -> Encoding omitField :: Key -> Bool ``` -------------------------------- ### KeyMap HashMap Conversion Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides functions to convert between KeyMap and HashMap. This allows leveraging HashMap's performance characteristics when needed. ```Haskell fromHashMap :: HashMap Key v -> KeyMap v toHashMap :: KeyMap v -> HashMap Key v fromHashMapText :: HashMap Text v -> KeyMap v toHashMapText :: KeyMap v -> HashMap Text v coercionToHashMap :: Maybe (Coercion (HashMap Key v) (KeyMap v)) ``` -------------------------------- ### Aeson KeyValue Encoding Series (.=) Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-Encoding Defines the KeyValue instance for Encoding and Series, using the (.=) operator to create key-value pairs for encoding. ```Haskell Instance detailsDefined in Data.Aeson.Types.ToJSON Methods(.=) :: ToJSON v => Key -> v -> Series Source #explicitToField :: (v -> Encoding) -> Key -> v -> Series Source # ``` -------------------------------- ### Aeson Template Haskell Helpers Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/doc-index-All Utility functions using Template Haskell to automatically derive JSON parsing and encoding instances for custom data types. This significantly reduces boilerplate code. ```Haskell mkLiftParseJSON :: Name -> DecsQ mkLiftParseJSON2 :: Name -> DecsQ mkLiftToEncoding :: Name -> DecsQ mkLiftToEncoding2 :: Name -> DecsQ mkLiftToJSON :: Name -> DecsQ mkLiftToJSON2 :: Name -> DecsQ ``` -------------------------------- ### Foldable Instance for KeyMap Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-KeyMap Provides a Foldable instance for KeyMap, enabling folding operations over the elements within a KeyMap. This includes functions like fold, foldMap, foldr, and foldl. ```Haskell fold :: Monoid m => KeyMap m -> m foldMap :: Monoid m => (a -> m) -> KeyMap a -> m foldMap' :: Monoid m => (a -> m) -> KeyMap a -> m foldr :: (a -> b -> b) -> b -> KeyMap a -> b foldr' :: (a -> b -> b) -> b -> KeyMap a -> b foldl :: (b -> a -> b) -> b -> KeyMap a -> b foldl' :: (b -> a -> b) -> b -> KeyMap a -> b foldr1 :: (a -> a -> a) -> KeyMap a -> a foldl1 :: (a -> a -> a) -> KeyMap a -> a toiList :: KeyMap a -> [a] null :: KeyMap a -> Bool length :: KeyMap a -> Int elem :: Eq a => a -> KeyMap a -> Bool maximum :: Ord a => KeyMap a -> a minimum :: Ord a => KeyMap a -> a sum :: Num a => KeyMap a -> a product :: Num a => KeyMap a -> a ``` -------------------------------- ### Haskell Data instance for Key Source: https://hackage.haskell.org/package/aeson-2.2.3.0/docs/Data-Aeson-Key Defines the Data instance for the Key type, enabling generic programming capabilities. This allows functions that operate on Data types to work with Key. ```Haskell gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Key -> c Key gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Key toConstr :: Key -> Constr dataTypeOf :: Key -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Key) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Key) gmapT :: (forall b. Data b => b -> b) -> Key -> Key gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r gmapQ :: (forall d. Data d => d -> u) -> Key -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Key -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Key -> m Key gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Key -> m Key gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Key -> m Key ```