module Stan.Inspection.All
( inspectionsMap
, inspections
, inspectionsIds
, lookupInspectionById
, getInspectionById
) where
import Stan.Core.Id (Id (..))
import Stan.Inspection (Inspection (..), InspectionsMap)
import Stan.Inspection.AntiPattern (antiPatternInspectionsMap)
import Stan.Inspection.Infinite (infiniteInspectionsMap)
import Stan.Inspection.Partial (partialInspectionsMap)
import Stan.Inspection.Style (styleInspectionsMap)
import qualified Data.HashMap.Strict as HM
inspectionsMap :: InspectionsMap
inspectionsMap :: InspectionsMap
inspectionsMap =
InspectionsMap
partialInspectionsMap
InspectionsMap -> InspectionsMap -> InspectionsMap
forall a. Semigroup a => a -> a -> a
<> InspectionsMap
infiniteInspectionsMap
InspectionsMap -> InspectionsMap -> InspectionsMap
forall a. Semigroup a => a -> a -> a
<> InspectionsMap
antiPatternInspectionsMap
InspectionsMap -> InspectionsMap -> InspectionsMap
forall a. Semigroup a => a -> a -> a
<> InspectionsMap
styleInspectionsMap
inspections :: [Inspection]
inspections :: [Inspection]
inspections = (Inspection -> Id Inspection) -> [Inspection] -> [Inspection]
forall b a. Ord b => (a -> b) -> [a] -> [a]
sortWith Inspection -> Id Inspection
inspectionId ([Inspection] -> [Inspection]) -> [Inspection] -> [Inspection]
forall a b. (a -> b) -> a -> b
$ InspectionsMap -> [Inspection]
forall k v. HashMap k v -> [v]
HM.elems InspectionsMap
inspectionsMap
inspectionsIds :: HashSet (Id Inspection)
inspectionsIds :: HashSet (Id Inspection)
inspectionsIds = InspectionsMap -> HashSet (Id Inspection)
forall k a. HashMap k a -> HashSet k
HM.keysSet InspectionsMap
inspectionsMap
lookupInspectionById :: Id Inspection -> Maybe Inspection
lookupInspectionById :: Id Inspection -> Maybe Inspection
lookupInspectionById insId :: Id Inspection
insId = Id Inspection -> InspectionsMap -> Maybe Inspection
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
HM.lookup Id Inspection
insId InspectionsMap
inspectionsMap
{-# INLINE lookupInspectionById #-}
getInspectionById :: Id Inspection -> Inspection
getInspectionById :: Id Inspection -> Inspection
getInspectionById insId :: Id Inspection
insId = case Id Inspection -> Maybe Inspection
lookupInspectionById Id Inspection
insId of
Just ins :: Inspection
ins -> Inspection
ins
Nothing -> Text -> Inspection
forall a t. (HasCallStack, IsText t) => t -> a
error (Text -> Inspection) -> Text -> Inspection
forall a b. (a -> b) -> a -> b
$ "Unknown Inspection ID: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Id Inspection -> Text
forall a. Id a -> Text
unId Id Inspection
insId