Skip to content

Commit

Permalink
Fixup RestylerOverrides parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrisbin committed Oct 18, 2024
1 parent 8a24b1b commit 983198b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Restyler/Config/Restyler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Restyler.Prelude hiding ((.=))

import Autodocodec
import Data.Aeson (Value (..))
import Data.Aeson.Key qualified as Key
import Data.Aeson.KeyMap qualified as KeyMap
import Data.Aeson.Types (parseEither)
import Data.HashMap.Strict qualified as HashMap
Expand Down Expand Up @@ -86,9 +87,10 @@ codecNamed :: JSONCodec RestylerOverride
codecNamed =
bimapCodec
( \case
Object km -> do
obj <- note "No name key" $ KeyMap.lookup "name" km
parseEither (parseJSONVia codecObject) obj
Object km | [(name, Object os)] <- KeyMap.toList km -> do
parseEither (parseJSONVia codecObject)
$ Object
$ KeyMap.insert "name" (String $ Key.toText name) os
_ -> Left "Not an Object"
)
(const "unused")
Expand Down

0 comments on commit 983198b

Please sign in to comment.