packages feed

lens-aeson 1.0.2 → 1.1

raw patch · 6 files changed

+277/−110 lines, 6 filesdep ~aesondep ~bytestringdep ~doctestPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: aeson, bytestring, doctest

API changes (from Hackage documentation)

+ Data.Aeson.Lens: _JSON' :: (AsJSON t, FromJSON a, ToJSON a) => Prism' t a
+ Data.Aeson.Lens: pattern Bool_ :: AsPrimitive t => Bool -> t
+ Data.Aeson.Lens: pattern Double :: AsNumber t => Double -> t
+ Data.Aeson.Lens: pattern Integer :: AsNumber t => Integer -> t
+ Data.Aeson.Lens: pattern Primitive :: AsPrimitive t => Primitive -> t
+ Data.Aeson.Lens: pattern Number_ :: AsNumber t => Scientific -> t
+ Data.Aeson.Lens: pattern String_ :: AsPrimitive t => Text -> t
+ Data.Aeson.Lens: pattern Integral :: (AsNumber t, Integral a) => a -> t
+ Data.Aeson.Lens: pattern Null_ :: AsPrimitive t => t
- Data.Aeson.Lens: _JSON :: (AsJSON t, FromJSON a, ToJSON a) => Prism' t a
+ Data.Aeson.Lens: _JSON :: (AsJSON t, FromJSON a, ToJSON b) => Prism t t a b
- Data.Aeson.Lens: class AsNumber t where _Number = _Primitive . _Number _Double = _Number . iso toRealFloat realToFrac _Integer = _Number . iso floor fromIntegral
+ Data.Aeson.Lens: class AsNumber t
- Data.Aeson.Lens: class AsNumber t => AsPrimitive t where _Primitive = _Value . _Primitive _String = _Primitive . prism StringPrim (\ v -> case v of { StringPrim s -> Right s _ -> Left v }) _Bool = _Primitive . prism BoolPrim (\ v -> case v of { BoolPrim b -> Right b _ -> Left v }) _Null = _Primitive . prism (const NullPrim) (\ v -> case v of { NullPrim -> Right () _ -> Left v })
+ Data.Aeson.Lens: class AsNumber t => AsPrimitive t
- Data.Aeson.Lens: class AsPrimitive t => AsValue t where _Object = _Value . prism Object (\ v -> case v of { Object o -> Right o _ -> Left v }) _Array = _Value . prism Array (\ v -> case v of { Array a -> Right a _ -> Left v })
+ Data.Aeson.Lens: class AsPrimitive t => AsValue t

Files

.gitignore view
@@ -12,3 +12,21 @@ *.hi *~ *#+.stack-work/+cabal-dev+*.chi+*.chs.h+*.dyn_o+*.dyn_hi+.hpc+.hsenv+.cabal-sandbox/+cabal.sandbox.config+*.prof+*.aux+*.hp+*.eventlog+cabal.project.local+cabal.project.local~+.HTF/+.ghc.environment.*
.travis.yml view
@@ -1,106 +1,175 @@-# This file has been generated -- see https://github.com/hvr/multi-ghc-travis+# This Travis job script has been generated by a script via+#+#   haskell-ci '--output=.travis.yml' '--config=cabal.haskell-ci' 'cabal.project'+#+# For more information, see https://github.com/haskell-CI/haskell-ci+#+# version: 0.5.20180830+# language: c-sudo: false-+dist: xenial+git:+  # whether to recursively clone submodules+  submodules: false+notifications:+  irc:+    channels:+      - irc.freenode.org#haskell-lens+    skip_join: true+    template:+      - "\"\\x0313lens-aeson\\x03/\\x0306%{branch}\\x03 \\x0314%{commit}\\x03 %{build_url} %{message}\"" cache:   directories:-    - $HOME/.cabsnap     - $HOME/.cabal/packages-+    - $HOME/.cabal/store before_cache:-  - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log-  - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar-+  - rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log+  # remove files that are regenerated by 'cabal update'+  - rm -fv $CABALHOME/packages/hackage.haskell.org/00-index.*+  - rm -fv $CABALHOME/packages/hackage.haskell.org/*.json+  - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.cache+  - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar+  - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar.idx+  - rm -rfv $CABALHOME/packages/head.hackage matrix:   include:-    - env: CABALVER=1.24 GHCVER=7.4.2-      compiler: ": #GHC 7.4.2"-      addons: {apt: {packages: [cabal-install-1.24,ghc-7.4.2,hlint], sources: [hvr-ghc]}}-    - env: CABALVER=1.24 GHCVER=7.6.3-      compiler: ": #GHC 7.6.3"-      addons: {apt: {packages: [cabal-install-1.24,ghc-7.6.3,hlint], sources: [hvr-ghc]}}-    - env: CABALVER=1.24 GHCVER=7.8.4-      compiler: ": #GHC 7.8.4"-      addons: {apt: {packages: [cabal-install-1.24,ghc-7.8.4,hlint], sources: [hvr-ghc]}}-    - env: CABALVER=1.24 GHCVER=7.10.3-      compiler: ": #GHC 7.10.3"-      addons: {apt: {packages: [cabal-install-1.24,ghc-7.10.3,hlint], sources: [hvr-ghc]}}-    - env: CABALVER=1.24 GHCVER=8.0.2-      compiler: ": #GHC 8.0.2"-      addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.2,hlint], sources: [hvr-ghc]}}-    - env: CABALVER=2.0 GHCVER=8.2.1-      compiler: ": #GHC 8.2.1"-      addons: {apt: {packages: [cabal-install-2.0,ghc-8.2.1,hlint], sources: [hvr-ghc]}}-    - env: CABALVER=head GHCVER=head-      compiler: ": #GHC head"-      addons: {apt: {packages: [cabal-install-head,ghc-head,hlint], sources: [hvr-ghc]}}-+    - compiler: ghc-8.8.1+      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.8.1","cabal-install-3.0"]}}+    - compiler: ghc-8.6.5+      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.5","cabal-install-3.0"]}}+    - compiler: ghc-8.4.4+      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.4.4","cabal-install-3.0"]}}+    - compiler: ghc-8.2.2+      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.2.2","cabal-install-3.0"]}}+    - compiler: ghc-8.0.2+      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.0.2","cabal-install-3.0"]}}+    - compiler: ghc-7.10.3+      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.10.3","cabal-install-3.0"]}}+    - compiler: ghc-7.8.4+      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.8.4","cabal-install-3.0"]}}+    - compiler: ghc-7.6.3+      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.6.3","cabal-install-3.0"]}}+    - compiler: ghc-7.4.2+      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.4.2","cabal-install-3.0"]}}+    - compiler: ghc-head+      addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-head","cabal-install-head"]}}   allow_failures:-    - env: CABALVER=head GHCVER=head-+    - compiler: ghc-head before_install:- - unset CC- - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH-+  - HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')+  - WITHCOMPILER="-w $HC"+  - HADDOCK=$(echo "/opt/$CC/bin/haddock" | sed 's/-/\//')+  - HCPKG="$HC-pkg"+  - unset CC+  - CABAL=/opt/ghc/bin/cabal+  - CABALHOME=$HOME/.cabal+  - export PATH="$CABALHOME/bin:$PATH"+  - TOP=$(pwd)+  - "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"+  - echo $HCNUMVER+  - CABAL="$CABAL -vnormal+nowrap+markoutput"+  - set -o pipefail+  - |+    echo 'function blue(s) { printf "\033[0;34m" s "\033[0m " }'           >> .colorful.awk+    echo 'BEGIN { state = "output"; }'                                     >> .colorful.awk+    echo '/^-----BEGIN CABAL OUTPUT-----$/ { state = "cabal" }'            >> .colorful.awk+    echo '/^-----END CABAL OUTPUT-----$/ { state = "output" }'             >> .colorful.awk+    echo '!/^(-----BEGIN CABAL OUTPUT-----|-----END CABAL OUTPUT-----)/ {' >> .colorful.awk+    echo '  if (state == "cabal") {'                                       >> .colorful.awk+    echo '    print blue($0)'                                              >> .colorful.awk+    echo '  } else {'                                                      >> .colorful.awk+    echo '    print $0'                                                    >> .colorful.awk+    echo '  }'                                                             >> .colorful.awk+    echo '}'                                                               >> .colorful.awk+  - cat .colorful.awk+  - |+    color_cabal_output () {+      awk -f $TOP/.colorful.awk+    }+  - echo text | color_cabal_output install:- - cabal --version- - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"- - if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];-   then-     zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >-          $HOME/.cabal/packages/hackage.haskell.org/00-index.tar;-   fi- - travis_retry cabal update -v- - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config- - cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt- - sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt--# check whether current requested install-plan matches cached package-db snapshot- - if diff -u installplan.txt $HOME/.cabsnap/installplan.txt;-   then-     echo "cabal build-cache HIT";-     rm -rfv .ghc;-     cp -a $HOME/.cabsnap/ghc $HOME/.ghc;-     cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;-   else-     echo "cabal build-cache MISS";-     rm -rf $HOME/.cabsnap;-     mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;-     cabal install -j --only-dependencies --enable-tests --enable-benchmarks;-   fi--# snapshot package-db on cache miss- - if [ ! -d $HOME/.cabsnap ];-   then-      echo "snapshotting package-db to build-cache";-      mkdir $HOME/.cabsnap;-      cp -a $HOME/.ghc $HOME/.cabsnap/ghc;-      cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;-   fi--# Here starts the actual work to be performed for the package under test;-# any command which exits with a non-zero exit code causes the build to fail.+  - ${CABAL} --version+  - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"+  - TEST=--enable-tests+  - BENCH=--enable-benchmarks+  - HEADHACKAGE=false+  - if [ $HCNUMVER -gt 80801 ] ; then HEADHACKAGE=true ; fi+  - rm -f $CABALHOME/config+  - |+    echo "verbose: normal +nowrap +markoutput"          >> $CABALHOME/config+    echo "remote-build-reporting: anonymous"            >> $CABALHOME/config+    echo "write-ghc-environment-files: always"          >> $CABALHOME/config+    echo "remote-repo-cache: $CABALHOME/packages"       >> $CABALHOME/config+    echo "logs-dir:          $CABALHOME/logs"           >> $CABALHOME/config+    echo "world-file:        $CABALHOME/world"          >> $CABALHOME/config+    echo "extra-prog-path:   $CABALHOME/bin"            >> $CABALHOME/config+    echo "symlink-bindir:    $CABALHOME/bin"            >> $CABALHOME/config+    echo "installdir:        $CABALHOME/bin"            >> $CABALHOME/config+    echo "build-summary:     $CABALHOME/logs/build.log" >> $CABALHOME/config+    echo "store-dir:         $CABALHOME/store"          >> $CABALHOME/config+    echo "install-dirs user"                            >> $CABALHOME/config+    echo "  prefix: $CABALHOME"                         >> $CABALHOME/config+    echo "repository hackage.haskell.org"               >> $CABALHOME/config+    echo "  url: http://hackage.haskell.org/"           >> $CABALHOME/config+  - |+    if $HEADHACKAGE; then+    echo "allow-newer: $($HCPKG list --simple-output | sed -E 's/([a-zA-Z-]+)-[0-9.]+/*:\1/g')" >> $CABALHOME/config+    echo "repository head.hackage.ghc.haskell.org"                                        >> $CABALHOME/config+    echo "   url: https://ghc.gitlab.haskell.org/head.hackage/"                           >> $CABALHOME/config+    echo "   secure: True"                                                                >> $CABALHOME/config+    echo "   root-keys: 7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d" >> $CABALHOME/config+    echo "              26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329" >> $CABALHOME/config+    echo "              f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89" >> $CABALHOME/config+    echo "   key-threshold: 3"                                                            >> $CABALHOME/config+    fi+  - cat $CABALHOME/config+  - rm -fv cabal.project cabal.project.local cabal.project.freeze+  - travis_retry ${CABAL} v2-update -v+  - if [ $HCNUMVER -ge 80800 ] && [ $HCNUMVER -lt 80802 ] ; then (cd /tmp && ${CABAL} v2-install $WITHCOMPILER -j2 hlint --constraint='hlint ==2.1.*' | color_cabal_output) ; fi+  # Generate cabal.project+  - rm -rf cabal.project cabal.project.local cabal.project.freeze+  - touch cabal.project+  - |+    echo "packages: ." >> cabal.project+  - |+  - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(lens-aeson)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"+  - cat cabal.project || true+  - cat cabal.project.local || true+  - if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi+  - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH} | color_cabal_output+  - "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"+  - rm  cabal.project.freeze+  - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} --dep -j2 all | color_cabal_output script:- - cabal configure -v2 --enable-tests --enable-benchmarks  # -v2 provides useful information for debugging- - cabal build # this builds all libraries and executables (including tests/benchmarks)- - cabal test- - cabal sdist   # tests that a source-distribution can be generated- - hlint src --cpp-define HLINT- - export SRC_TGZ=$(cabal info . | awk '{print $2 ".tar.gz";exit}') ;-   cd dist/;-   if [ -f "$SRC_TGZ" ]; then-      cabal install "$SRC_TGZ";-   else-      echo "expected '$SRC_TGZ' not found";-      exit 1;-   fi--notifications:-  irc:-    channels:-      - "irc.freenode.org#haskell-lens"-    skip_join: true-    template:-      - "\x0313lens-aeson\x0f/\x0306%{branch}\x0f \x0314%{commit}\x0f %{message} \x0302\x1f%{build_url}\x0f"+  - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)+  # Packaging...+  - ${CABAL} v2-sdist all | color_cabal_output+  # Unpacking...+  - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/+  - cd ${DISTDIR} || false+  - find . -maxdepth 1 -type f -name '*.tar.gz' -exec tar -xvf '{}' \;+  - find . -maxdepth 1 -type f -name '*.tar.gz' -exec rm       '{}' \;+  - PKGDIR_lens_aeson="$(find . -maxdepth 1 -type d -regex '.*/lens-aeson-[0-9.]*')"+  # Generate cabal.project+  - rm -rf cabal.project cabal.project.local cabal.project.freeze+  - touch cabal.project+  - |+    echo "packages: ${PKGDIR_lens_aeson}" >> cabal.project+  - |+  - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(lens-aeson)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"+  - cat cabal.project || true+  - cat cabal.project.local || true+  # Building with tests and benchmarks...+  # build & run tests, build benchmarks+  - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output+  # Testing...+  - ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output+  # HLint..+  - if [ $HCNUMVER -ge 80800 ] && [ $HCNUMVER -lt 80802 ] ; then (cd ${PKGDIR_lens_aeson} && hlint --cpp-ansi --cpp-define=HLINT src) ; fi+  # cabal check...+  - (cd ${PKGDIR_lens_aeson} && ${CABAL} -vnormal check)+  # haddock...+  - ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all | color_cabal_output +# REGENDATA ["--output=.travis.yml","--config=cabal.haskell-ci","cabal.project"] # EOF
CHANGELOG.markdown view
@@ -1,3 +1,12 @@+1.1 [2019.09.26]+----------------+* Generalize the type of `_JSON` from `Prism' t a` to `Prism t t a b`. If you+  wish to continue to use the less general type, use the newly added `_JSON'`+  prism.+* Add pattern synonyms corresponding to the `Prism`s that `lens-aeson`+  provides.+* Fix the test suite on 32-bit architectures.+ 1.0.2 ----- * Support `doctest-0.12`
README.markdown view
@@ -1,7 +1,7 @@ lens-aeson ========== -[![Hackage](https://img.shields.io/hackage/v/lens-aeson.svg)](https://hackage.haskell.org/package/lens-aeson) [![Build Status](https://secure.travis-ci.org/ekmett/linear.svg)](http://travis-ci.org/lens/lens-aeson)+[![Hackage](https://img.shields.io/hackage/v/lens-aeson.svg)](https://hackage.haskell.org/package/lens-aeson) [![Build Status](https://secure.travis-ci.org/lens/lens-aeson.svg)](http://travis-ci.org/lens/lens-aeson)  The goal of `lens-aeson` is to provide traversals and prisms for the [Aeson](http://hackage.haskell.org/package/aeson) library's
lens-aeson.cabal view
@@ -1,6 +1,6 @@ name:          lens-aeson category:      Numeric-version:       1.0.2+version:       1.1 license:       MIT cabal-version: >= 1.8 license-file:  LICENSE@@ -13,9 +13,17 @@   Copyright (C) 2012 Paul Wilson   Copyright (C) 2013 Edward A. Kmett build-type:    Custom-tested-with:   GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC==8.0.2, GHC==8.2.1+tested-with:   GHC == 7.4.2+             , GHC == 7.6.3+             , GHC == 7.8.4+             , GHC == 7.10.3+             , GHC == 8.0.2+             , GHC == 8.2.2+             , GHC == 8.4.4+             , GHC == 8.6.5+             , GHC == 8.8.1 synopsis:      Law-abiding lenses for aeson-description:   Law-abiding lenses for aeson+description:   Law-abiding lenses for aeson.  extra-source-files:   .travis.yml@@ -53,7 +61,7 @@     unordered-containers >= 0.2.3     && < 0.3,     attoparsec           >= 0.10      && < 0.14,     bytestring           >= 0.9       && < 0.11,-    aeson                >= 0.7.0.5   && < 1.3,+    aeson                >= 0.7.0.5   && < 1.5,     scientific           >= 0.3.2     && < 0.4    exposed-modules:@@ -73,7 +81,7 @@   else     build-depends:       base,-      doctest        >= 0.11.1 && < 0.13,+      doctest        >= 0.11.1 && < 0.17,       generic-deriving,       lens-aeson,       semigroups     >= 0.9,
src/Data/Aeson/Lens.hs view
@@ -8,9 +8,13 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE DefaultSignatures #-} {-# OPTIONS_GHC -fno-warn-orphans #-}+#if __GLASGOW_HASKELL__ >= 800+{-# LANGUAGE PatternSynonyms #-}+{-# LANGUAGE ViewPatterns #-}+#endif -------------------------------------------------------------------- -- |--- Copyright :  (c) Edward Kmett 2013-2014, (c) Paul Wilson 2012+-- Copyright :  (c) Edward Kmett 2013-2019, (c) Paul Wilson 2012 -- License   :  BSD3 -- Maintainer:  Edward Kmett <ekmett@gmail.com> -- Stability :  experimental@@ -34,6 +38,20 @@   , nth, values   -- * Decoding   , AsJSON(..)+  , _JSON'+  -- * Pattern Synonyms+#if __GLASGOW_HASKELL__ >= 800+  , pattern JSON+  , pattern Value_+  , pattern Number_+  , pattern Double+  , pattern Integer+  , pattern Integral+  , pattern Primitive+  , pattern Bool_+  , pattern String_+  , pattern Null_+#endif   ) where  import Control.Applicative@@ -72,11 +90,9 @@   -- >>> "[1, \"x\"]" ^? nth 1 . _Number   -- Nothing   _Number :: Prism' t Scientific-#ifndef HLINT   default _Number :: AsPrimitive t => Prism' t Scientific   _Number = _Primitive._Number   {-# INLINE _Number #-}-#endif    -- |   -- Prism into an 'Double' over a 'Value', 'Primitive' or 'Scientific'@@ -164,11 +180,9 @@   -- >>> "[1, \"x\", null, true, false]" ^? nth 4 . _Primitive   -- Just (BoolPrim False)   _Primitive :: Prism' t Primitive-#ifndef HLINT   default _Primitive :: AsValue t => Prism' t Primitive   _Primitive = _Value._Primitive   {-# INLINE _Primitive #-}-#endif    -- |   -- >>> "{\"a\": \"xyz\", \"b\": true}" ^? key "a" . _String@@ -328,11 +342,11 @@  -- | An indexed Traversal into Object properties ----- >>> "{\"a\": 4, \"b\": 7}" ^@.. members--- [("a",Number 4.0),("b",Number 7.0)]+-- >>> Data.List.sort ("{\"a\": 4, \"b\": 7}" ^@.. members . _Number)+-- [("a",4.0),("b",7.0)] ----- >>> "{\"a\": 4, \"b\": 7}" & members . _Number *~ 10--- "{\"a\":40,\"b\":70}"+-- >>> "{\"a\": 4}" & members . _Number *~ 10+-- "{\"a\":40}" members :: AsValue t => IndexedTraversal' Text t Value members = _Object . itraversed {-# INLINE members #-}@@ -342,7 +356,7 @@ -- >>> "[1,2,3]" ^? nth 1 -- Just (Number 2.0) ----- >>> "\"a\": 100, \"b\": 200}" ^? nth 1+-- >>> "{\"a\": 100, \"b\": 200}" ^? nth 1 -- Nothing -- -- >>> "[1,2,3]" & nth 1 .~ Number 20@@ -371,9 +385,12 @@ lazyTextUtf8 :: Iso' LazyText.Text Lazy.ByteString lazyTextUtf8 = iso LazyText.encodeUtf8 LazyText.decodeUtf8 +_JSON' :: (AsJSON t, FromJSON a, ToJSON a) => Prism' t a+_JSON' = _JSON+ class AsJSON t where   -- | '_JSON' is a 'Prism' from something containing JSON to something encoded in that structure-  _JSON :: (FromJSON a, ToJSON a) => Prism' t a+  _JSON :: (FromJSON a, ToJSON b) => Prism t t a b  instance AsJSON Strict.ByteString where   _JSON = lazy._JSON@@ -457,3 +474,49 @@   plate f (Array a) = Array <$> traverse f a   plate _ xs = pure xs   {-# INLINE plate #-}++------------------------------------------------------------------------------+-- Pattern Synonyms+------------------------------------------------------------------------------++#if __GLASGOW_HASKELL__ >= 800+pattern JSON :: (FromJSON a, ToJSON a, AsJSON t) => () => a -> t+pattern JSON a <- (preview _JSON -> Just a) where+  JSON a = _JSON # a++pattern Value_ :: (FromJSON a, ToJSON a) => () => a -> Value+pattern Value_ a <- (fromJSON -> Success a) where+  Value_ a = toJSON a++pattern Number_ :: AsNumber t => Scientific -> t+pattern Number_ n <- (preview _Number -> Just n) where+  Number_ n = _Number # n++pattern Double :: AsNumber t => Double -> t+pattern Double d <- (preview _Double -> Just d) where+  Double d = _Double # d++pattern Integer :: AsNumber t => Integer -> t+pattern Integer i <- (preview _Integer -> Just i) where+  Integer i = _Integer # i++pattern Integral :: (AsNumber t, Integral a) => a -> t+pattern Integral d <- (preview _Integral -> Just d) where+  Integral d = _Integral # d++pattern Primitive :: AsPrimitive t => Primitive -> t+pattern Primitive p <- (preview _Primitive -> Just p) where+  Primitive p = _Primitive # p++pattern Bool_ :: AsPrimitive t => Bool -> t+pattern Bool_ b <- (preview _Bool -> Just b) where+  Bool_ b = _Bool # b++pattern String_ :: AsPrimitive t => Text -> t+pattern String_ p <- (preview _String -> Just p) where+  String_ p = _String # p++pattern Null_ :: AsPrimitive t => t+pattern Null_ <- (preview _Null -> Just ()) where+  Null_ = _Null # ()+#endif