summaryrefslogtreecommitdiff
path: root/lib/Types.hs
diff options
context:
space:
mode:
authorstuebinm2021-09-20 20:41:31 +0200
committerstuebinm2021-09-20 20:41:31 +0200
commit727f2cbc5feb3cdd30df3c78f39ba4a58e6c4832 (patch)
tree4b70ceeefc5f05b9aecff85488faf471adbcfa4d /lib/Types.hs
parentd3548568e33e830bc2bdb8dc51e48ad880747a12 (diff)
simple parsing of local dependency paths
Diffstat (limited to '')
-rw-r--r--lib/Types.hs16
1 files changed, 7 insertions, 9 deletions
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 <> "]"