{-# LANGUAGE CPP #-}

{- |
Copyright: (c) 2020 Kowainik
SPDX-License-Identifier: MPL-2.0
Maintainer: Kowainik <xrom.xkov@gmail.com>

Contains all 'Inspection's for partial functions.

The __partial__ inspections are in ranges:

* @STAN-0001 .. STAN-0100@
-}

module Stan.Inspection.Partial
    ( -- * Partial 'Inspection's
      -- *** Partial 'GHC.List.head'
      stan0001
      -- *** Partial 'GHC.List.tail'
    , stan0002
      -- *** Partial 'GHC.List.init'
    , stan0003
      -- *** Partial 'GHC.List.last'
    , stan0004
      -- *** Partial 'GHC.List.!!'
    , stan0005
      -- *** Partial 'GHC.List.cycle'
    , stan0006
      -- *** Partial 'Data.OldList.genericIndex'
    , stan0007
      -- *** Partial 'Data.Maybe.fromJust'
    , stan0008
      -- *** Partial 'Text.Read.read'
    , stan0009
      -- *** Partial 'GHC.Enum.succ'
    , stan0010
      -- *** Partial 'GHC.Enum.pred'
    , stan0011
      -- *** Partial 'GHC.Enum.toEnum'
    , stan0012
      -- *** Partial 'Data.Foldable.maximum'
    , stan0013
      -- *** Partial 'Data.Foldable.minimum'
    , stan0014
      -- *** Partial 'Data.Foldable.maximumBy'
    , stan0015
      -- *** Partial 'Data.Foldable.minimumBy'
    , stan0016
      -- *** Partial 'Data.Foldable.foldl1'
    , stan0017
      -- *** Partial 'Data.Foldable.foldl1\''
    , stan0018
      -- *** Partial 'Data.Foldable.foldr1'
    , stan0019
      -- *** Partial instance for 'NonEmpty' method 'GHC.Exts.fromList'
    , stan0020
      -- *** Partial instance for 'Natural' method 'GHC.Num.fromInteger'
    , stan0021
      -- *** Partial instance for 'Scientific' method 'GHC.Real.fromRational'
    , stan0022
      -- *** Partial 'Scientific' function 'GHC.Real.realToFrac'
    , stan0023
      -- *** Partial instance for 'Scientific' method 'GHC.Real.recip'
    , stan0024
      -- *** Partial instance for 'Scientific' method 'GHC.Real.(/)'
    , stan0025
      -- * List of all partial 'Inspection's
    , partialInspectionsMap
    ) where

import Prelude hiding ((&&&))
import Relude.Extra.Lens ((%~), (.~))
import Relude.Extra.Tuple (fmapToFst)

import Stan.Core.Id (Id (..))
import Stan.Inspection (Inspection (..), InspectionAnalysis (..), InspectionsMap, analysisL,
                        categoryL, descriptionL, solutionL)
import Stan.NameMeta (NameMeta (..), baseNameFrom, mkBaseFoldableMeta, mkBaseListMeta,
                      mkBaseOldListMeta, _nameFrom)
import Stan.Pattern.Ast (PatternAst (PatternAstName), namesToPatternAst)
import Stan.Pattern.Edsl (PatternBool (..))
import Stan.Pattern.Type (PatternType (..), integerPattern, listFunPattern, listPattern,
                          naturalPattern, nonEmptyPattern, rationalPattern, scientificPattern, (|->))
import Stan.Severity (Severity (..))

import qualified Stan.Category as Category


-- | All partial 'Inspection's.
partialInspectionsMap :: InspectionsMap
partialInspectionsMap :: InspectionsMap
partialInspectionsMap = [Item InspectionsMap] -> InspectionsMap
forall l. IsList l => [Item l] -> l
fromList ([Item InspectionsMap] -> InspectionsMap)
-> [Item InspectionsMap] -> InspectionsMap
forall a b. (a -> b) -> a -> b
$ (Inspection -> Id Inspection)
-> [Inspection] -> [(Id Inspection, Inspection)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f (b, a)
fmapToFst Inspection -> Id Inspection
inspectionId
    [ Inspection
stan0001
    , Inspection
stan0002
    , Inspection
stan0003
    , Inspection
stan0004
    , Inspection
stan0005
    , Inspection
stan0006
    , Inspection
stan0007
    , Inspection
stan0008
    , Inspection
stan0009
    , Inspection
stan0010
    , Inspection
stan0011
    , Inspection
stan0012
    , Inspection
stan0013
    , Inspection
stan0014
    , Inspection
stan0015
    , Inspection
stan0016
    , Inspection
stan0017
    , Inspection
stan0018
    , Inspection
stan0019
    , Inspection
stan0020
    , Inspection
stan0021
    , Inspection
stan0022
    , Inspection
stan0023
    , Inspection
stan0024
    , Inspection
stan0025
    ]

-- | Smart constructor to create generic partial 'Inspection' with a given 'Pattern'.
mkPartialInspectionPattern
    :: Id Inspection
    -> NameMeta
    -> PatternType
    -> Text  -- ^ Type name
    -> Inspection
mkPartialInspectionPattern :: Id Inspection -> NameMeta -> PatternType -> Text -> Inspection
mkPartialInspectionPattern Id Inspection
insId nameMeta :: NameMeta
nameMeta@NameMeta{Text
ModuleName
nameMetaPackage :: Text
nameMetaModuleName :: ModuleName
nameMetaName :: Text
nameMetaPackage :: NameMeta -> Text
nameMetaModuleName :: NameMeta -> ModuleName
nameMetaName :: NameMeta -> Text
..} PatternType
pat Text
typeName = Inspection
    { inspectionId :: Id Inspection
inspectionId = Id Inspection
insId
    , inspectionName :: Text
inspectionName = Text
"Partial: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
nameMetaPackage Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
nameMetaName
    , inspectionDescription :: Text
inspectionDescription = Text -> Text -> Text
usage Text
nameMetaName Text
typeName
    , inspectionSolution :: [Text]
inspectionSolution = []
    , inspectionCategory :: NonEmpty Category
inspectionCategory = OneItem (NonEmpty Category) -> NonEmpty Category
forall x. One x => OneItem x -> x
one OneItem (NonEmpty Category)
Category
Category.partial
    , inspectionSeverity :: Severity
inspectionSeverity = Severity
Warning
    , inspectionAnalysis :: InspectionAnalysis
inspectionAnalysis = PatternAst -> InspectionAnalysis
FindAst (PatternAst -> InspectionAnalysis)
-> PatternAst -> InspectionAnalysis
forall a b. (a -> b) -> a -> b
$ NameMeta -> PatternType -> PatternAst
PatternAstName NameMeta
nameMeta PatternType
pat
    }

-- | Smart constructor to create generic partial 'Inspection' with 'PatternAnything'.
mkPartialInspection
    :: Id Inspection
    -> NameMeta
    -> Text  -- ^ Type name
    -> Inspection
mkPartialInspection :: Id Inspection -> NameMeta -> Text -> Inspection
mkPartialInspection Id Inspection
insId NameMeta
nameMeta =
    Id Inspection -> NameMeta -> PatternType -> Text -> Inspection
mkPartialInspectionPattern Id Inspection
insId NameMeta
nameMeta PatternType
forall a. PatternBool a => a
(?)

usage :: Text -> Text -> Text
usage :: Text -> Text -> Text
usage Text
funName Text
forWhat =
    Text
"Usage of partial function '" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
funName Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"' for " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
forWhat

{- | Smart constructor to create partial 'Inspection' for functions
that work with lists.
-}
mkPartialInspectionList :: Id Inspection -> NameMeta -> Inspection
mkPartialInspectionList :: Id Inspection -> NameMeta -> Inspection
mkPartialInspectionList Id Inspection
insId NameMeta
nameMeta = Id Inspection -> NameMeta -> Text -> Inspection
mkPartialInspection Id Inspection
insId NameMeta
nameMeta Text
"lists"
    Inspection -> (Inspection -> Inspection) -> Inspection
forall a b. a -> (a -> b) -> b
& (NonEmpty Category -> f (NonEmpty Category))
-> Inspection -> f Inspection
Lens' Inspection (NonEmpty Category)
categoryL Lens' Inspection (NonEmpty Category)
-> (NonEmpty Category -> NonEmpty Category)
-> Inspection
-> Inspection
forall s a. Lens' s a -> (a -> a) -> s -> s
%~ (NonEmpty Category -> NonEmpty Category -> NonEmpty Category
forall a. Semigroup a => a -> a -> a
<> OneItem (NonEmpty Category) -> NonEmpty Category
forall x. One x => OneItem x -> x
one OneItem (NonEmpty Category)
Category
Category.list)
    Inspection -> (Inspection -> Inspection) -> Inspection
forall a b. a -> (a -> b) -> b
& ([Text] -> f [Text]) -> Inspection -> f Inspection
Lens' Inspection [Text]
solutionL Lens' Inspection [Text] -> [Text] -> Inspection -> Inspection
forall s a. Lens' s a -> a -> s -> s
.~
        [ Text
"Replace list with 'NonEmpty' from 'Data.List.NonEmpty'"
        , Text
"Use explicit pattern-matching over lists"
        ]

{- | Smart constructor to create partial 'Inspection' for functions
that work with enumerable types.
-}
mkPartialInspectionEnum :: Id Inspection -> Text -> PatternType -> [Text] -> Inspection
mkPartialInspectionEnum :: Id Inspection -> Text -> PatternType -> [Text] -> Inspection
mkPartialInspectionEnum Id Inspection
insId Text
funName PatternType
pat [Text]
solution =
    Id Inspection -> NameMeta -> PatternType -> Text -> Inspection
mkPartialInspectionPattern Id Inspection
insId NameMeta
enumMeta PatternType
pat Text
""
    Inspection -> (Inspection -> Inspection) -> Inspection
forall a b. a -> (a -> b) -> b
& (Text -> f Text) -> Inspection -> f Inspection
Lens' Inspection Text
descriptionL Lens' Inspection Text -> Text -> Inspection -> Inspection
forall s a. Lens' s a -> a -> s -> s
.~ Text -> Text -> Text
usage Text
funName Text
"enumerable types"
    Inspection -> (Inspection -> Inspection) -> Inspection
forall a b. a -> (a -> b) -> b
& ([Text] -> f [Text]) -> Inspection -> f Inspection
Lens' Inspection [Text]
solutionL Lens' Inspection [Text] -> [Text] -> Inspection -> Inspection
forall s a. Lens' s a -> a -> s -> s
.~ [Text]
solution
  where
    enumMeta :: NameMeta
    enumMeta :: NameMeta
enumMeta =
#if __GLASGOW_HASKELL__ < 910
      Text
funName Text -> ModuleName -> NameMeta
`_nameFrom` ModuleName
"GHC.Enum"
#else
      funName `_nameFrom` "GHC.Internal.Enum"
#endif

-- | 'Inspection' — partial 'GHC.List.head' @STAN-0001@.
stan0001 :: Inspection
stan0001 :: Inspection
stan0001 = Id Inspection -> NameMeta -> Inspection
mkPartialInspectionList (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0001") (Text -> NameMeta
mkBaseListMeta Text
"head")

-- | 'Inspection' — partial 'GHC.List.tail' @STAN-0002@.
stan0002 :: Inspection
stan0002 :: Inspection
stan0002 = Id Inspection -> NameMeta -> Inspection
mkPartialInspectionList (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0002") (Text -> NameMeta
mkBaseListMeta Text
"tail")

-- | 'Inspection' — partial 'GHC.List.init' @STAN-0003@.
stan0003 :: Inspection
stan0003 :: Inspection
stan0003 = Id Inspection -> NameMeta -> Inspection
mkPartialInspectionList (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0003") (Text -> NameMeta
mkBaseListMeta Text
"init")

-- | 'Inspection' — partial 'GHC.List.last' @STAN-0004@.
stan0004 :: Inspection
stan0004 :: Inspection
stan0004 = Id Inspection -> NameMeta -> Inspection
mkPartialInspectionList (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0004") (Text -> NameMeta
mkBaseListMeta Text
"last")

-- | 'Inspection' — partial 'GHC.List.!!' @STAN-0005@.
stan0005 :: Inspection
stan0005 :: Inspection
stan0005 = Id Inspection -> NameMeta -> Inspection
mkPartialInspectionList (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0005") (Text -> NameMeta
mkBaseListMeta Text
"!!")
    Inspection -> (Inspection -> Inspection) -> Inspection
forall a b. a -> (a -> b) -> b
& ([Text] -> f [Text]) -> Inspection -> f Inspection
Lens' Inspection [Text]
solutionL Lens' Inspection [Text] -> [Text] -> Inspection -> Inspection
forall s a. Lens' s a -> a -> s -> s
.~ []

-- | 'Inspection' — partial 'GHC.List.cycle' @STAN-0006@.
stan0006 :: Inspection
stan0006 :: Inspection
stan0006 = Id Inspection -> NameMeta -> Inspection
mkPartialInspectionList (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0006") (Text -> NameMeta
mkBaseListMeta Text
"cycle")

-- | 'Inspection' — partial 'Data.OldList.genericIndex' @STAN-0007@.
stan0007 :: Inspection
stan0007 :: Inspection
stan0007 = Id Inspection -> NameMeta -> Inspection
mkPartialInspectionList (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0007") (Text -> NameMeta
mkBaseOldListMeta Text
"genericIndex")
    Inspection -> (Inspection -> Inspection) -> Inspection
forall a b. a -> (a -> b) -> b
& ([Text] -> f [Text]) -> Inspection -> f Inspection
Lens' Inspection [Text]
solutionL Lens' Inspection [Text] -> [Text] -> Inspection -> Inspection
forall s a. Lens' s a -> a -> s -> s
.~ []

-- | 'Inspection' — partial 'Data.Maybe.fromJust' @STAN-0008@.
stan0008 :: Inspection
stan0008 :: Inspection
stan0008 = Id Inspection -> NameMeta -> Text -> Inspection
mkPartialInspection (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0008") NameMeta
fromJustNameMeta Text
"'Maybe'"
    Inspection -> (Inspection -> Inspection) -> Inspection
forall a b. a -> (a -> b) -> b
& ([Text] -> f [Text]) -> Inspection -> f Inspection
Lens' Inspection [Text]
solutionL Lens' Inspection [Text] -> [Text] -> Inspection -> Inspection
forall s a. Lens' s a -> a -> s -> s
.~
        [ Text
"Use explicit pattern-matching over Maybe"
        , Text
"Use one of the standard functions: 'maybe', 'fromMaybe'"
        ]
  where
    fromJustNameMeta :: NameMeta
    fromJustNameMeta :: NameMeta
fromJustNameMeta =
#if __GLASGOW_HASKELL__ < 910
      Text
"fromJust" Text -> ModuleName -> NameMeta
`_nameFrom` ModuleName
"Data.Maybe"
#else
      "fromJust" `_nameFrom` "GHC.Internal.Data.Maybe"
#endif

-- | 'Inspection' — partial 'Text.Read.read' @STAN-0009@.
stan0009 :: Inspection
stan0009 :: Inspection
stan0009 = Id Inspection -> NameMeta -> Text -> Inspection
mkPartialInspection (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0009") NameMeta
readNameMeta Text
""
    Inspection -> (Inspection -> Inspection) -> Inspection
forall a b. a -> (a -> b) -> b
& (Text -> f Text) -> Inspection -> f Inspection
Lens' Inspection Text
descriptionL Lens' Inspection Text -> Text -> Inspection -> Inspection
forall s a. Lens' s a -> a -> s -> s
.~ Text -> Text -> Text
usage Text
"read" Text
"parsing 'String'"
    Inspection -> (Inspection -> Inspection) -> Inspection
forall a b. a -> (a -> b) -> b
& ([Text] -> f [Text]) -> Inspection -> f Inspection
Lens' Inspection [Text]
solutionL Lens' Inspection [Text] -> [Text] -> Inspection -> Inspection
forall s a. Lens' s a -> a -> s -> s
.~
        [ Text
"Use 'readMaybe' or 'readEither' to handle failed parsing"
        ]
  where
    readNameMeta :: NameMeta
    readNameMeta :: NameMeta
readNameMeta =
#if __GLASGOW_HASKELL__ < 910
      Text
"read" Text -> ModuleName -> NameMeta
`_nameFrom` ModuleName
"Text.Read"
#else
      "read" `_nameFrom` "GHC.Internal.Text.Read"
#endif

-- | 'Inspection' — partial 'GHC.Enum.succ' @STAN-0010@.
stan0010 :: Inspection
stan0010 :: Inspection
stan0010 = Id Inspection -> Text -> PatternType -> [Text] -> Inspection
mkPartialInspectionEnum
    (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0010")
    Text
"succ"
    (PatternType -> PatternType
forall a. PatternBool a => a -> a
neg (PatternType
integerPattern PatternType -> PatternType -> PatternType
|-> PatternType
forall a. PatternBool a => a
(?)) PatternType -> PatternType -> PatternType
forall a. PatternBool a => a -> a -> a
&&& PatternType -> PatternType
forall a. PatternBool a => a -> a
neg (PatternType
naturalPattern PatternType -> PatternType -> PatternType
|-> PatternType
forall a. PatternBool a => a
(?)))
    [ Text
"Use '(+ 1)' for integral types (but be aware of arithmetic overflow)"
    , Text
"{Extra dependency} Use 'next' from 'Relude.Extra.Enum' in 'relude'"
    ]

-- | 'Inspection' — partial 'GHC.Enum.pred' @STAN-0011@.
stan0011 :: Inspection
stan0011 :: Inspection
stan0011 = Id Inspection -> Text -> PatternType -> [Text] -> Inspection
mkPartialInspectionEnum
    (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0011")
    Text
"pred"
    (PatternType -> PatternType
forall a. PatternBool a => a -> a
neg (PatternType
integerPattern PatternType -> PatternType -> PatternType
|-> PatternType
forall a. PatternBool a => a
(?)))
    [ Text
"Use '(- 1)' for integral types (but be aware of arithmetic overflow)"
    , Text
"{Extra dependency} Use 'prev' from 'Relude.Extra.Enum' in 'relude'"
    ]

-- | 'Inspection' — partial 'GHC.Enum.toEnum' @STAN-0012@.
stan0012 :: Inspection
stan0012 :: Inspection
stan0012 = Id Inspection -> Text -> PatternType -> [Text] -> Inspection
mkPartialInspectionEnum (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0012") Text
"toEnum" PatternType
forall a. PatternBool a => a
(?)
    [ Text
"{Extra dependency} Use 'safeToEnum' from 'Relude.Extra.Enum' in 'relude'"
    ]

-- | 'Inspection' — partial 'Data.Foldable.maximum' @STAN-0013@.
stan0013 :: Inspection
stan0013 :: Inspection
stan0013 = Id Inspection -> NameMeta -> PatternType -> Text -> Inspection
mkPartialInspectionPattern
    (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0013") (Text -> NameMeta
mkBaseFoldableMeta Text
"maximum") PatternType
listFunPattern Text
""

-- | 'Inspection' — partial 'Data.Foldable.minimum' @STAN-0014@.
stan0014 :: Inspection
stan0014 :: Inspection
stan0014 = Id Inspection -> NameMeta -> PatternType -> Text -> Inspection
mkPartialInspectionPattern
    (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0014") (Text -> NameMeta
mkBaseFoldableMeta Text
"minimum") PatternType
listFunPattern Text
""

orderingFunPattern :: PatternType
orderingFunPattern :: PatternType
orderingFunPattern = PatternType
forall a. PatternBool a => a
(?) PatternType -> PatternType -> PatternType
|-> PatternType
listFunPattern

-- | 'Inspection' — partial 'Data.Foldable.maximumBy' @STAN-0015@.
stan0015 :: Inspection
stan0015 :: Inspection
stan0015 = Id Inspection -> NameMeta -> PatternType -> Text -> Inspection
mkPartialInspectionPattern
    (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0015") (Text -> NameMeta
mkBaseFoldableMeta Text
"maximumBy") PatternType
orderingFunPattern Text
""

-- | 'Inspection' — partial 'Data.Foldable.minimumBy' @STAN-0016@.
stan0016 :: Inspection
stan0016 :: Inspection
stan0016 = Id Inspection -> NameMeta -> PatternType -> Text -> Inspection
mkPartialInspectionPattern
    (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0016") (Text -> NameMeta
mkBaseFoldableMeta Text
"minimumBy") PatternType
orderingFunPattern Text
""

-- | 'Inspection' — partial 'Data.Foldable.foldl1' @STAN-0017@.
stan0017 :: Inspection
stan0017 :: Inspection
stan0017 = Id Inspection -> NameMeta -> PatternType -> Text -> Inspection
mkPartialInspectionPattern
    (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0017") (Text -> NameMeta
mkBaseFoldableMeta Text
"foldl1") PatternType
orderingFunPattern Text
""

-- | 'Inspection' — partial 'Data.Foldable.foldl1\'' @STAN-0018@.
stan0018 :: Inspection
stan0018 :: Inspection
stan0018 = Id Inspection -> NameMeta -> Inspection
mkPartialInspectionList (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0018") (Text -> NameMeta
mkBaseListMeta Text
"foldl1'")

-- | 'Inspection' — partial 'Data.Foldable.foldr1' @STAN-0019@.
stan0019 :: Inspection
stan0019 :: Inspection
stan0019 = Id Inspection -> NameMeta -> PatternType -> Text -> Inspection
mkPartialInspectionPattern
    (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0019") (Text -> NameMeta
mkBaseFoldableMeta Text
"foldr1") PatternType
orderingFunPattern Text
""

-- | 'Inspection' — partial 'GHC.Exts.fromList' @STAN-0020@.
stan0020 :: Inspection
stan0020 :: Inspection
stan0020 = Id Inspection -> NameMeta -> PatternType -> Text -> Inspection
mkPartialInspectionPattern (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0020") NameMeta
exts PatternType
pat Text
""
    Inspection -> (Inspection -> Inspection) -> Inspection
forall a b. a -> (a -> b) -> b
& (InspectionAnalysis -> f InspectionAnalysis)
-> Inspection -> f Inspection
Lens' Inspection InspectionAnalysis
analysisL Lens' Inspection InspectionAnalysis
-> InspectionAnalysis -> Inspection -> Inspection
forall s a. Lens' s a -> a -> s -> s
.~ PatternAst -> InspectionAnalysis
FindAst (NonEmpty (NameMeta, PatternType) -> PatternAst
namesToPatternAst (NonEmpty (NameMeta, PatternType) -> PatternAst)
-> NonEmpty (NameMeta, PatternType) -> PatternAst
forall a b. (a -> b) -> a -> b
$ (NameMeta
exts, PatternType
pat) (NameMeta, PatternType)
-> [(NameMeta, PatternType)] -> NonEmpty (NameMeta, PatternType)
forall a. a -> [a] -> NonEmpty a
:| [(NameMeta
ne, PatternType
pat)])
  where
    pat :: PatternType
pat = PatternType
listPattern PatternType -> PatternType -> PatternType
|-> PatternType
nonEmptyPattern
#if __GLASGOW_HASKELL__ < 904
    exts = "fromList" `baseNameFrom` "GHC.Exts"
#elif __GLASGOW_HASKELL__ < 910
    exts :: NameMeta
exts = Text
"fromList" Text -> ModuleName -> NameMeta
`baseNameFrom` ModuleName
"GHC.IsList"
#else
    exts = "fromList" `_nameFrom` "GHC.Internal.IsList"
#endif
    ne :: NameMeta
ne = Text
"fromList" Text -> ModuleName -> NameMeta
`baseNameFrom` ModuleName
"Data.List.NonEmpty"

-- | 'Inspection' — partial 'GHC.Num.fromInteger' @STAN-0021@.
stan0021 :: Inspection
stan0021 :: Inspection
stan0021 = Id Inspection -> NameMeta -> PatternType -> Text -> Inspection
mkPartialInspectionPattern
    (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0021")
#if __GLASGOW_HASKELL__ < 910
    (Text
"fromInteger" Text -> ModuleName -> NameMeta
`_nameFrom` ModuleName
"GHC.Num")
#else
    ("fromInteger" `_nameFrom` "GHC.Internal.Num")
#endif
    (PatternType
integerPattern PatternType -> PatternType -> PatternType
|-> PatternType
naturalPattern)
    Text
""

-- | 'Inspection' — partial 'GHC.Real.fromRational' @STAN-0022@.
stan0022 :: Inspection
stan0022 :: Inspection
stan0022 = Id Inspection -> NameMeta -> PatternType -> Text -> Inspection
mkPartialInspectionPattern
    (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0022")
#if __GLASGOW_HASKELL__ < 910
    (Text
"fromRational" Text -> ModuleName -> NameMeta
`_nameFrom` ModuleName
"GHC.Real")
#else
    ("fromRational" `_nameFrom` "GHC.Internal.Real")
#endif
    (PatternType
rationalPattern PatternType -> PatternType -> PatternType
|-> PatternType
scientificPattern)
    Text
"Scientific"
    Inspection -> (Inspection -> Inspection) -> Inspection
forall a b. a -> (a -> b) -> b
& ([Text] -> f [Text]) -> Inspection -> f Inspection
Lens' Inspection [Text]
solutionL Lens' Inspection [Text] -> [Text] -> Inspection -> Inspection
forall s a. Lens' s a -> a -> s -> s
.~
        [ Text
"Use a function like 'Data.Scientific.fromRationalRepetend' that handles repeating decimals"
        , Text
"Convert to a fractional type like 'Double'"
        ]

-- | 'Inspection' — partial 'GHC.Real.realToFrac' @STAN-0023@.
stan0023 :: Inspection
stan0023 :: Inspection
stan0023 = Id Inspection -> NameMeta -> PatternType -> Text -> Inspection
mkPartialInspectionPattern
    (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0023")
#if __GLASGOW_HASKELL__ < 910
    (Text
"realToFrac" Text -> ModuleName -> NameMeta
`_nameFrom` ModuleName
"GHC.Real")
#else
    ("realToFrac" `_nameFrom` "GHC.Internal.Real")
#endif
    (PatternType
forall a. PatternBool a => a
(?) PatternType -> PatternType -> PatternType
|-> PatternType
scientificPattern)
    Text
"Scientific"
    Inspection -> (Inspection -> Inspection) -> Inspection
forall a b. a -> (a -> b) -> b
& ([Text] -> f [Text]) -> Inspection -> f Inspection
Lens' Inspection [Text]
solutionL Lens' Inspection [Text] -> [Text] -> Inspection -> Inspection
forall s a. Lens' s a -> a -> s -> s
.~
        [ Text
"Use 'Data.Scientific.fromFloatDigits'"
        , Text
"use a function that handles repeating decimals, e.g. 'Data.Scientific.fromRationalRepetend . toRational'"
        ]

-- | 'Inspection' - partial 'GHC.Real.recip' @STAN-0024@
stan0024 :: Inspection
stan0024 :: Inspection
stan0024 = Id Inspection -> NameMeta -> PatternType -> Text -> Inspection
mkPartialInspectionPattern
    (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0024")
#if __GLASGOW_HASKELL__ < 910
    (Text
"recip" Text -> ModuleName -> NameMeta
`_nameFrom` ModuleName
"GHC.Real")
#else
    ("recip" `_nameFrom` "GHC.Internal.Real")
#endif
    (PatternType
scientificPattern PatternType -> PatternType -> PatternType
|-> PatternType
scientificPattern)
    Text
"Scientific"
    Inspection -> (Inspection -> Inspection) -> Inspection
forall a b. a -> (a -> b) -> b
& ([Text] -> f [Text]) -> Inspection -> f Inspection
Lens' Inspection [Text]
solutionL Lens' Inspection [Text] -> [Text] -> Inspection -> Inspection
forall s a. Lens' s a -> a -> s -> s
.~
        [ Text
"Convert to a fractional type like 'Double'"
        ]

-- | 'Inspection' - partial 'GHC.Real.(/)' @STAN-0025@
stan0025 :: Inspection
stan0025 :: Inspection
stan0025 = Id Inspection -> NameMeta -> PatternType -> Text -> Inspection
mkPartialInspectionPattern
    (Text -> Id Inspection
forall a. Text -> Id a
Id Text
"STAN-0025")
#if __GLASGOW_HASKELL__ < 910
    (Text
"/" Text -> ModuleName -> NameMeta
`_nameFrom` ModuleName
"GHC.Real")
#else
    ("/" `_nameFrom` "GHC.Internal.Real")
#endif
    (PatternType
scientificPattern PatternType -> PatternType -> PatternType
|-> PatternType
scientificPattern PatternType -> PatternType -> PatternType
|-> PatternType
scientificPattern)
    Text
"Scientific"
    Inspection -> (Inspection -> Inspection) -> Inspection
forall a b. a -> (a -> b) -> b
& ([Text] -> f [Text]) -> Inspection -> f Inspection
Lens' Inspection [Text]
solutionL Lens' Inspection [Text] -> [Text] -> Inspection -> Inspection
forall s a. Lens' s a -> a -> s -> s
.~
        [ Text
"Convert to a fractional type like 'Double'"
        ]