summaryrefslogtreecommitdiff
path: root/lib/Types.hs
diff options
context:
space:
mode:
authorstuebinm2021-09-18 23:21:15 +0200
committerstuebinm2021-09-18 23:21:15 +0200
commitccb57f9a16b47aab55f786b976b0b8e89ff49f36 (patch)
treece757ccdf2eb0bfde8bcfc3cf28dab602cc5643b /lib/Types.hs
parent0bd2e836d96fe864b00d2085f29e932130722cc3 (diff)
collecting map dependencies
Diffstat (limited to 'lib/Types.hs')
-rw-r--r--lib/Types.hs25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/Types.hs b/lib/Types.hs
index 79bbfab..2e683c0 100644
--- a/lib/Types.hs
+++ b/lib/Types.hs
@@ -1,5 +1,6 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
@@ -27,8 +28,8 @@ data Level = Warning | Suggestion | Info | Forbidden | Error | Fatal
data Lint = Depends Dep | Lint Hint
-- | TODO: add a reasonable representation of possible urls
-newtype Dep = Dep Text
- deriving (Generic, ToJSON)
+data Dep = Local Text | Link Text | MapLink Text | LocalMap Text
+ deriving (Generic)
data Hint = Hint
{ hintLevel :: Level
@@ -42,8 +43,8 @@ hint level msg = Lint Hint { hintLevel = level, hintMsg = msg }
-- | dependencies just have level Info
lintLevel :: Lint -> Level
-lintLevel (Lint h) = hintLevel h
-lintLevel (Depends dep) = Info
+lintLevel (Lint h) = hintLevel h
+lintLevel (Depends _) = Info
instance PrettyPrint Lint where
prettyprint (Lint Hint { hintMsg, hintLevel } ) =
@@ -57,5 +58,19 @@ instance ToJSON Lint where
[ "hintMsg" .= prettyprint dep
, "hintLevel" .= A.String "Dependency Info" ]
+instance ToJSON Dep where
+ toJSON = \case
+ Local text -> json "local" text
+ Link text -> json "link" text
+ MapLink text -> json "mapservice" text
+ LocalMap text -> json "map" text
+ where
+ json :: A.Value -> Text -> A.Value
+ json kind text = A.object [ "kind" .= kind, "dep" .= text ]
+
instance PrettyPrint Dep where
- prettyprint (Dep txt) = txt
+ prettyprint = \case
+ Local dep -> "[local dep: " <> dep <> "]"
+ Link dep -> "[link dep: " <> dep <> "]"
+ MapLink dep -> "[map service dep: " <> dep <> "]"
+ LocalMap dep -> "[local map dep: " <> dep <> "]"