File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -129,12 +129,17 @@ configCmdSetScope (ConfigCmdSetSystemGhc scope _) = scope
129129configCmdSetScope (ConfigCmdSetInstallGhc scope _) = scope
130130
131131encodeDumpProject :: RawYaml -> ConfigDumpFormat -> Project -> ByteString
132- encodeDumpProject rawConfig ConfigDumpYaml p = let e = Yaml. encode p in
133- Yaml. decodeEither' e & either ( const e) (\ (d :: KeyMap Yaml. Value ) ->
132+ encodeDumpProject rawConfig format p
133+ | ConfigDumpYaml <- format = dumpProject (\ e d ->
134134 either (const e) encodeUtf8 (cfgRedress rawConfig d " " ))
135- encodeDumpProject rawConfig ConfigDumpJson p = let e = Yaml. encode p in
136- Yaml. decodeEither' e & either (const e) (\ (d :: KeyMap Yaml. Value ) ->
137- toStrictBytes $ encodePretty' (Aeson. defConfig{confCompare = cfgKeyCompare rawConfig d " " }) d)
135+ | ConfigDumpJson <- format = dumpProject (\ _ d ->
136+ let cmp = cfgKeyCompare rawConfig d " "
137+ in toStrictBytes $ encodePretty' (Aeson. defConfig{confCompare = cmp}) d)
138+ where
139+ -- REVIEW: Is there a way to encode straight to keymap?
140+ -- encode project to bytestring then decode to keymap.
141+ dumpProject f = let e = Yaml. encode p in Yaml. decodeEither' e &
142+ either (const e) (\ (d :: KeyMap Yaml. Value ) -> f e d)
138143
139144cfgKeyCompare :: RawYaml -> KeyMap Yaml. Value -> Text -> (Text -> Text -> Ordering )
140145cfgKeyCompare (yamlLines -> configLines) (fmap Key. toText . KeyMap. keys -> keys) cmdKey =
You can’t perform that action at this time.
0 commit comments