Skip to content

Commit 18b2f48

Browse files
committed
Use where instead of let for setting up aeson config.
1 parent cfaa3f5 commit 18b2f48

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Stack/ConfigCmd.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,15 @@ encodeDumpProject rawConfig format p
133133
| ConfigDumpYaml <- format = dumpProject (\e d ->
134134
either (const e) encodeUtf8 (cfgRedress rawConfig d ""))
135135
| ConfigDumpJson <- format = dumpProject (\_ d ->
136-
let cmp = cfgKeyCompare rawConfig d ""
137-
in toStrictBytes $ encodePretty' (Aeson.defConfig{confCompare = cmp}) d)
136+
toStrictBytes $ encodePretty' (cfgPretty d) d)
138137
where
139138
-- REVIEW: Is there a way to encode straight to keymap?
140139
-- encode project to bytestring then decode to keymap.
141140
dumpProject f = let e = Yaml.encode p in Yaml.decodeEither' e &
142141
either (const e) (\(d :: KeyMap Yaml.Value) -> f e d)
143142

143+
cfgPretty d = Aeson.defConfig{confCompare = cfgKeyCompare rawConfig d ""}
144+
144145
cfgKeyCompare :: RawYaml -> KeyMap Yaml.Value -> Text -> (Text -> Text -> Ordering)
145146
cfgKeyCompare (yamlLines -> configLines) (fmap Key.toText . KeyMap.keys -> keys) cmdKey =
146147
compareInOrder configLines (coerce keys) (coerce cmdKey)

0 commit comments

Comments
 (0)