generated from freckle/haskell-library-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.lhs
80 lines (62 loc) · 2.31 KB
/
README.lhs
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# aeson-compat
[![Hackage](https://img.shields.io/hackage/v/aeson-compat.svg?style=flat)](https://hackage.haskell.org/package/aeson-compat)
[![Stackage Nightly](http://stackage.org/package/aeson-compat/badge/nightly)](http://stackage.org/nightly/package/aeson-compat)
[![Stackage LTS](http://stackage.org/package/aeson-compat/badge/lts)](http://stackage.org/lts/package/aeson-compat)
[![CI](https://github.com/freckle/aeson-compat/actions/workflows/ci.yml/badge.svg)](https://github.com/freckle/aeson-compat/actions/workflows/ci.yml)
Compatibility package between aeson major versions.
## Organization
This library contains modules named `Data.Aeson.VN.M`, which
1. Present the same interface as `Data.Aeson.M` as of aeson `vN`, and
2. Compile with all versions of aeson
## Example
<!--
```haskell
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
module Main (main) where
import Prelude
import Text.Markdown.Unlit ()
```
-->
```haskell
import Data.Aeson
import qualified Data.Aeson.V2.Key as Key
import qualified Data.Aeson.V2.KeyMap as KeyMap
someExample :: IO ()
someExample = putStrLn
$ unwords
$ map Key.toString
$ KeyMap.keys
$ (\(Object km) -> km)
$ object
[ "hello" .= True
, "world" .= True
]
```
<!--
```haskell
main :: IO ()
main = someExample
```
-->
## Gotchas
There are cases where it's not practical to match the aeson functionality
exactly when we're making compatibility functions against older (or newer)
versions. The following lists concessions we've made.
- Our version of `alterF` (`unordered-containers < 0.2.10`) may compute the hash
key multiple times, since we don't have access to the internals necessary to
pre-compute the key once and use it for any lookup, insert, and delete
actions.
- We may use strict implementations for should-be lazy functions (or vice
versa). For example, in `unordered-containers < 0.2.11`, `foldl = foldl'` and
`foldr' = foldr`.
- Only one of `coercionToHashMap` or `coercionToMap` will be `Just`, depending
on your actual aeson version.
- Either conversions dealing with `HashMap` or those dealing with `Map` will be
fast (runtime-erased), depending on your actual aeson version.
## Development & Tests
```console
stack build --fast --pedantic --test --file-watch
```
---
[CHANGELOG](./CHANGELOG.md) | [LICENSE](./LICENSE)