Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 25 lines (23 sloc) 0.572 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE Rank2Types #-}
-- |
-- This is a small example of how to construct a projection for a third-party library like
-- @aeson@.
--
-- To test this:
--
-- > doctest Aeson.hs
module Aeson where

import Control.Lens
import Data.Aeson
import Data.ByteString.Lazy

-- |
-- >>> 5^.by aeson
-- "5"
-- >>> [1,2,3]^.by aeson
-- "[1,2,3]"
-- >>> aeson.both +~ 2 $ (2,3)^.by aeson
-- "[4,5]"
aeson, aeson' :: (FromJSON c, ToJSON d) => Projection ByteString ByteString c d
aeson = projection encode decode
aeson' = projection encode decode'
Something went wrong with that request. Please try again.