summaryrefslogtreecommitdiff
path: root/Biz/Namespace.hs
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2022-08-03 14:11:18 -0400
committerBen Sima <ben@bsima.me>2022-08-03 15:20:01 -0400
commit27a631b2c94df80ac5da8c97b66a3e99e1813811 (patch)
treef706daa9710b7412d23f1dea4288cd22318e0039 /Biz/Namespace.hs
parent935d5dc1c8d4c60a70d79a3f47718f9dcf5684fd (diff)
Print bild JSON analysis as a dictionary instead of a stream
Diffstat (limited to 'Biz/Namespace.hs')
-rw-r--r--Biz/Namespace.hs5
1 files changed, 5 insertions, 0 deletions
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