Skip to content

Commit 498d676

Browse files
vijayphoenixjaspervdj
authored andcommitted
Switch to HsYAML library
1 parent bb91eb7 commit 498d676

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ cabal.config
1818
cabal.sandbox.config
1919
cabal.sandbox.config
2020
dist
21+
/dist-newstyle/

lib/Language/Haskell/Stylish/Config.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ import Data.Aeson (FromJSON (..)
1616
import qualified Data.Aeson as A
1717
import qualified Data.Aeson.Types as A
1818
import qualified Data.ByteString as B
19+
import Data.ByteString.Lazy (fromStrict)
1920
import Data.Char (toLower)
2021
import qualified Data.FileEmbed as FileEmbed
2122
import Data.List (intercalate,
2223
nub)
2324
import Data.Map (Map)
2425
import qualified Data.Map as M
2526
import Data.Maybe (fromMaybe)
26-
import Data.Yaml (decodeEither',
27-
prettyPrintParseException)
27+
import Data.YAML (prettyPosWithSource)
28+
import Data.YAML.Aeson (decode1Strict)
2829
import System.Directory
2930
import System.FilePath ((</>))
3031
import qualified System.IO as IO (Newline (..),
@@ -101,9 +102,8 @@ loadConfig verbose userSpecified = do
101102
mbFp <- configFilePath verbose userSpecified
102103
verbose $ "Loading configuration at " ++ fromMaybe "<embedded>" mbFp
103104
bytes <- maybe (return defaultConfigBytes) B.readFile mbFp
104-
case decodeEither' bytes of
105-
Left err -> error $
106-
"Language.Haskell.Stylish.Config.loadConfig: " ++ prettyPrintParseException err
105+
case decode1Strict bytes of
106+
Left (pos, err) -> error $ prettyPosWithSource pos (fromStrict bytes) ("Language.Haskell.Stylish.Config.loadConfig: " ++ err)
107107
Right config -> do
108108
cabalLanguageExtensions <- if configCabal config
109109
then map show <$> Cabal.findLanguageExtensions verbose

stack.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ packages:
55
extra-deps:
66
- 'Cabal-3.0.0.0'
77
- 'haskell-src-exts-1.23.0'
8+
- 'HsYAML-0.2.1.0'
9+
- 'HsYAML-aeson-0.2.0.0'

stack.yaml.lock

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ packages:
1818
sha256: 8e5bc885533431db9bf75e9609f6b80b56ab0c289a903d701f8628e78322afd0
1919
original:
2020
hackage: haskell-src-exts-1.23.0
21+
- completed:
22+
hackage: HsYAML-0.2.1.0@sha256:e4677daeba57f7a1e9a709a1f3022fe937336c91513e893166bd1f023f530d68,5311
23+
pantry-tree:
24+
size: 1340
25+
sha256: 21f61bf9cad31674126b106071dd9b852e408796aeffc90eec1792f784107eff
26+
original:
27+
hackage: HsYAML-0.2.1.0
28+
- completed:
29+
hackage: HsYAML-aeson-0.2.0.0@sha256:04796abfc01cffded83f37a10e6edba4f0c0a15d45bef44fc5bb4313d9c87757,1791
30+
pantry-tree:
31+
size: 234
32+
sha256: 67cc9ba17c79e71d3abdb465a3ee2825477856fff3b8b7d543cbbbefdae9a9d9
33+
original:
34+
hackage: HsYAML-aeson-0.2.0.0
2135
snapshots:
2236
- completed:
2337
size: 524154

stylish-haskell.cabal

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ Library
6464
mtl >= 2.0 && < 2.3,
6565
semigroups >= 0.18 && < 0.20,
6666
syb >= 0.3 && < 0.8,
67-
yaml >= 0.8.11 && < 0.12
67+
HsYAML-aeson >=0.2.0 && < 0.3,
68+
HsYAML >=0.2.0 && < 0.3
6869

6970
Executable stylish-haskell
7071
Ghc-options: -Wall
@@ -87,7 +88,8 @@ Executable stylish-haskell
8788
haskell-src-exts >= 1.18 && < 1.24,
8889
mtl >= 2.0 && < 2.3,
8990
syb >= 0.3 && < 0.8,
90-
yaml >= 0.8.11 && < 0.12
91+
HsYAML-aeson >=0.2.0 && < 0.3,
92+
HsYAML >=0.2.0 && < 0.3
9193

9294
Test-suite stylish-haskell-tests
9395
Ghc-options: -Wall
@@ -146,7 +148,8 @@ Test-suite stylish-haskell-tests
146148
haskell-src-exts >= 1.18 && < 1.24,
147149
mtl >= 2.0 && < 2.3,
148150
syb >= 0.3 && < 0.8,
149-
yaml >= 0.8.11 && < 0.12
151+
HsYAML-aeson >=0.2.0 && < 0.3,
152+
HsYAML >=0.2.0 && < 0.3
150153

151154
Source-repository head
152155
Type: git

0 commit comments

Comments
 (0)