From 27a631b2c94df80ac5da8c97b66a3e99e1813811 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 3 Aug 2022 14:11:18 -0400 Subject: Print bild JSON analysis as a dictionary instead of a stream --- Biz/Namespace.hs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Biz/Namespace.hs') diff --git a/Biz/Namespace.hs b/Biz/Namespace.hs index cdc4464..72e3fa1 100644 --- a/Biz/Namespace.hs +++ b/Biz/Namespace.hs @@ -19,9 +19,11 @@ where import Alpha import qualified Data.Aeson as Aeson +import qualified Data.Aeson.Types as Aeson import qualified Data.Char as Char import qualified Data.List as List import qualified Data.List.Split as List +import qualified Data.Text as Text import qualified Text.Regex.Applicative as Regex data Ext @@ -43,6 +45,9 @@ data Ext data Namespace = Namespace {path :: [String], ext :: Ext} deriving (Eq, Show, Generic, Aeson.ToJSON, Ord) +instance Aeson.ToJSONKey Namespace where + toJSONKey = Aeson.toJSONKeyText (Text.pack <. toPath) + fromPath :: String -> String -> Maybe Namespace fromPath bizRoot absPath = List.stripPrefix bizRoot absPath -- cgit v1.2.3