diff options
Diffstat (limited to 'lib/Types.hs')
-rw-r--r-- | lib/Types.hs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Types.hs b/lib/Types.hs index c39297f..ab9f8a2 100644 --- a/lib/Types.hs +++ b/lib/Types.hs @@ -10,11 +10,12 @@ module Types where import Control.Monad.Trans.Maybe () -import Data.Aeson (ToJSON (toJSON), (.=)) +import Data.Aeson (ToJSON (toJSON), ToJSONKey, (.=)) import Data.Text (Text) import GHC.Generics (Generic) import qualified Data.Aeson as A +import Data.Maybe (mapMaybe) import Paths (RelPath) import Util (PrettyPrint (..), showText) import WithCli (Argument, Proxy (..), @@ -46,6 +47,7 @@ instance HasArguments Level where -- | a hint comes with an explanation (and a level), or is a dependency -- (in which case it'll be otherwise treated as an info hint) data Lint = Depends Dep | Offers Text | Lint Hint + deriving (Ord, Eq, Generic, ToJSONKey) -- | TODO: add a reasonable representation of possible urls data Dep = Local RelPath | Link Text | MapLink Text | LocalMap RelPath @@ -54,7 +56,7 @@ data Dep = Local RelPath | Link Text | MapLink Text | LocalMap RelPath data Hint = Hint { hintLevel :: Level , hintMsg :: Text - } deriving (Generic) + } deriving (Generic, Ord, Eq) -- | shorter constructor (called hint because (a) older name and -- (b) lint also exists and is monadic) @@ -66,6 +68,9 @@ lintLevel :: Lint -> Level lintLevel (Lint h) = hintLevel h lintLevel _ = Info +lintsToHints :: [Lint] -> [Hint] +lintsToHints = mapMaybe (\case {Lint hint -> Just hint ; _ -> Nothing}) + instance PrettyPrint Lint where prettyprint (Lint Hint { hintMsg, hintLevel } ) = " " <> showText hintLevel <> ": " <> hintMsg |