on master help sign in
Merge pull request #492 from andrewthad/other_pair_encoding

Add another function for building a key-value pair Encoding

commitf62d49272c370fd98b412e43e8272b7ede7ed5f6 authorAdam Bergmark <adam@bergmark.nl> dateThu 22 Dec 2016, 10:37 (10 years ago) parent9c3ba14ecc3485
2 files changed+6−1
Data/Aeson/Encoding.hs+1 Data/Aeson/Encoding/Internal.hs+5−1
Data/Aeson/Encoding.hs+1
@@ -14,6 +14,7 @@ module Data.Aeson.Encoding
1414 , Series
1515 , pairs
1616 , pair
17+ , pair'
1718 -- * Predicates
1819 , nullEncoding
1920 -- * Encoding constructors
Data/Aeson/Encoding/Internal.hs+5−1
@@ -13,6 +13,7 @@ module Data.Aeson.Encoding.Internal
1313 , Series (..)
1414 , pairs
1515 , pair
16+ , pair'
1617 -- * Predicates
1718 , nullEncoding
1819 -- * Encoding constructors
@@ -122,7 +123,10 @@ data Series = Empty
122123 deriving (Typeable)
123124
124125pair :: Text -> Encoding -> Series
125−pair name val = Value $ retagEncoding $ text name >< colon >< val
126+pair name val = pair' (text name) val
127+
128+pair' :: Encoding' Text -> Encoding -> Series
129+pair' name val = Value $ retagEncoding $ retagEncoding name >< colon >< val
126130
127131instance Semigroup Series where
128132 Empty <> a = a