From bfe45dc4996537b72436f4041d0ca819aa3444e1 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Fri, 17 Sep 2021 23:50:45 +0200 Subject: (somewhat) reasonable representation of parse errors This makes map loading (and parsing) part of the linter, and also makes it return "general lints" and nothing else in case that failed. Possibly a sum type would be nicer here, but I guess it's not really important since everything ends up as json anyways? --- src/Main.hs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/Main.hs') diff --git a/src/Main.hs b/src/Main.hs index f0af6c1..7884cf9 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE LambdaCase #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE NamedFieldPuns #-} @@ -8,14 +9,13 @@ module Main where import Data.Maybe (fromMaybe) import WithCli -import CheckMap (runLinter) +import CheckMap (loadAndLintMap) import Data.Aeson (encode) import Data.Aeson.Encode.Pretty (encodePretty) import qualified Data.ByteString.Lazy as LB import qualified Data.ByteString.Lazy.Encoding as LB import Data.Text.Lazy as T import System.IO (utf8) -import Tiled2 -- | the options this cli tool can take data Options = Options @@ -39,10 +39,7 @@ main = withCli run run :: Options -> IO () run options = do - -- TODO: what if parsing fails and we get Left err? - Right waMap <- loadTiledmap $ fromMaybe "example.json" (inpath options) - - let lints = runLinter waMap + lints <- loadAndLintMap (fromMaybe "example.json" (inpath options)) if json options then printLB -- cgit v1.2.3