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
129
129
configCmdSetScope (ConfigCmdSetInstallGhc scope _) = scope
130
130
131
131
encodeDumpProject :: 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 ->
134
134
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)
138
143
139
144
cfgKeyCompare :: RawYaml -> KeyMap Yaml. Value -> Text -> (Text -> Text -> Ordering )
140
145
cfgKeyCompare (yamlLines -> configLines) (fmap Key. toText . KeyMap. keys -> keys) cmdKey =
You can’t perform that action at this time.
0 commit comments