From 727f2cbc5feb3cdd30df3c78f39ba4a58e6c4832 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Mon, 20 Sep 2021 20:41:31 +0200 Subject: simple parsing of local dependency paths --- lib/Types.hs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'lib/Types.hs') diff --git a/lib/Types.hs b/lib/Types.hs index 2b67d47..5ec91a0 100644 --- a/lib/Types.hs +++ b/lib/Types.hs @@ -15,11 +15,9 @@ import Data.Text (Text) import GHC.Generics (Generic) import qualified Data.Aeson as A -import Tiled2 (Property (Property), - PropertyValue (BoolProp, StrProp)) +import Paths (RelPath) import Util (PrettyPrint (..), showText) - -- | Levels of errors and warnings, collectively called -- "Hints" until I can think of some better name data Level = Warning | Suggestion | Info | Forbidden | Error | Fatal @@ -30,7 +28,7 @@ data Level = Warning | Suggestion | Info | Forbidden | Error | Fatal data Lint = Depends Dep | Lint Hint -- | TODO: add a reasonable representation of possible urls -data Dep = Local Text | Link Text | MapLink Text | LocalMap Text +data Dep = Local RelPath | Link Text | MapLink Text | LocalMap RelPath deriving (Generic) data Hint = Hint @@ -38,7 +36,7 @@ data Hint = Hint , hintMsg :: Text } deriving (Generic, ToJSON) --- | shorter constructor (called lint because (a) older name and +-- | shorter constructor (called hint because (a) older name and -- (b) lint also exists and is monadic) hint :: Level -> Text -> Lint hint level msg = Lint Hint { hintLevel = level, hintMsg = msg } @@ -62,17 +60,17 @@ instance ToJSON Lint where instance ToJSON Dep where toJSON = \case - Local text -> json "local" text + Local text -> json "local" $ prettyprint text Link text -> json "link" text MapLink text -> json "mapservice" text - LocalMap text -> json "map" text + LocalMap text -> json "map" $ prettyprint text where json :: A.Value -> Text -> A.Value json kind text = A.object [ "kind" .= kind, "dep" .= text ] instance PrettyPrint Dep where prettyprint = \case - Local dep -> "[local dep: " <> dep <> "]" + Local dep -> "[local dep: " <> prettyprint dep <> "]" Link dep -> "[link dep: " <> dep <> "]" MapLink dep -> "[map service dep: " <> dep <> "]" - LocalMap dep -> "[local map dep: " <> dep <> "]" + LocalMap dep -> "[local map dep: " <> prettyprint dep <> "]" -- cgit v1.2.3