himari 1.1.6.3 → 1.1.6.4
raw patch · 23 files changed
+1032/−1004 lines, 23 filesdep +sandwichdep +sandwich-quickcheckdep −sydtestdep ~QuickCheckdep ~yamlPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
Dependencies added: sandwich, sandwich-quickcheck
Dependencies removed: sydtest
Dependency ranges changed: QuickCheck, yaml
API changes (from Hackage documentation)
+ Himari.Prelude: ConsultPolicy :: RetryAction
+ Himari.Prelude: ConsultPolicyOverrideDelay :: Int -> RetryAction
+ Himari.Prelude: DontRetry :: RetryAction
+ Himari.Prelude: RetryPolicyM :: (RetryStatus -> m (Maybe Int)) -> RetryPolicyM (m :: Type -> Type)
+ Himari.Prelude: RetryStatus :: !Int -> !Int -> !Maybe Int -> RetryStatus
+ Himari.Prelude: [getRetryPolicyM] :: RetryPolicyM (m :: Type -> Type) -> RetryStatus -> m (Maybe Int)
+ Himari.Prelude: [rsCumulativeDelay] :: RetryStatus -> !Int
+ Himari.Prelude: [rsIterNumber] :: RetryStatus -> !Int
+ Himari.Prelude: [rsPreviousDelay] :: RetryStatus -> !Maybe Int
+ Himari.Prelude: applyAndDelay :: MonadIO m => RetryPolicyM m -> RetryStatus -> m (Maybe RetryStatus)
+ Himari.Prelude: applyPolicy :: Monad m => RetryPolicyM m -> RetryStatus -> m (Maybe RetryStatus)
+ Himari.Prelude: capDelay :: forall (m :: Type -> Type). Monad m => Int -> RetryPolicyM m -> RetryPolicyM m
+ Himari.Prelude: constantDelay :: forall (m :: Type -> Type). Monad m => Int -> RetryPolicyM m
+ Himari.Prelude: data RetryAction
+ Himari.Prelude: data RetryStatus
+ Himari.Prelude: defaultLogMsg :: Exception e => Bool -> e -> RetryStatus -> String
+ Himari.Prelude: defaultRetryStatus :: RetryStatus
+ Himari.Prelude: exponentialBackoff :: forall (m :: Type -> Type). Monad m => Int -> RetryPolicyM m
+ Himari.Prelude: fibonacciBackoff :: forall (m :: Type -> Type). Monad m => Int -> RetryPolicyM m
+ Himari.Prelude: fullJitterBackoff :: forall (m :: Type -> Type). MonadIO m => Int -> RetryPolicyM m
+ Himari.Prelude: limitRetries :: Int -> RetryPolicy
+ Himari.Prelude: limitRetriesByCumulativeDelay :: forall (m :: Type -> Type). Monad m => Int -> RetryPolicyM m -> RetryPolicyM m
+ Himari.Prelude: limitRetriesByDelay :: forall (m :: Type -> Type). Monad m => Int -> RetryPolicyM m -> RetryPolicyM m
+ Himari.Prelude: logRetries :: (Monad m, Exception e) => (e -> m Bool) -> (Bool -> e -> RetryStatus -> m ()) -> RetryStatus -> Handler m Bool
+ Himari.Prelude: natTransformRetryPolicy :: (forall a. () => m a -> n a) -> RetryPolicyM m -> RetryPolicyM n
+ Himari.Prelude: newtype RetryPolicyM (m :: Type -> Type)
+ Himari.Prelude: recoverAll :: MonadUnliftIO m => RetryPolicyM m -> (RetryStatus -> m a) -> m a
+ Himari.Prelude: recovering :: MonadUnliftIO m => RetryPolicyM m -> [RetryStatus -> Handler m Bool] -> (RetryStatus -> m a) -> m a
+ Himari.Prelude: recoveringDynamic :: MonadUnliftIO m => RetryPolicyM m -> [RetryStatus -> Handler m RetryAction] -> (RetryStatus -> m a) -> m a
+ Himari.Prelude: resumeRecoverAll :: MonadUnliftIO m => RetryStatus -> RetryPolicyM m -> (RetryStatus -> m a) -> m a
+ Himari.Prelude: resumeRecovering :: MonadUnliftIO m => RetryStatus -> RetryPolicyM m -> [RetryStatus -> Handler m Bool] -> (RetryStatus -> m a) -> m a
+ Himari.Prelude: resumeRecoveringDynamic :: MonadUnliftIO m => RetryStatus -> RetryPolicyM m -> [RetryStatus -> Handler m RetryAction] -> (RetryStatus -> m a) -> m a
+ Himari.Prelude: resumeRetrying :: MonadIO m => RetryStatus -> RetryPolicyM m -> (RetryStatus -> b -> m Bool) -> (RetryStatus -> m b) -> m b
+ Himari.Prelude: resumeRetryingDynamic :: MonadIO m => RetryStatus -> RetryPolicyM m -> (RetryStatus -> b -> m RetryAction) -> (RetryStatus -> m b) -> m b
+ Himari.Prelude: retryOnError :: (Functor m, MonadIO m, MonadError e m) => RetryPolicyM m -> (RetryStatus -> e -> m Bool) -> (RetryStatus -> m a) -> m a
+ Himari.Prelude: retryPolicy :: forall (m :: Type -> Type). Monad m => (RetryStatus -> Maybe Int) -> RetryPolicyM m
+ Himari.Prelude: retryPolicyDefault :: forall (m :: Type -> Type). Monad m => RetryPolicyM m
+ Himari.Prelude: retrying :: MonadIO m => RetryPolicyM m -> (RetryStatus -> b -> m Bool) -> (RetryStatus -> m b) -> m b
+ Himari.Prelude: retryingDynamic :: MonadIO m => RetryPolicyM m -> (RetryStatus -> b -> m RetryAction) -> (RetryStatus -> m b) -> m b
+ Himari.Prelude: rsCumulativeDelayL :: Lens' RetryStatus Int
+ Himari.Prelude: rsIterNumberL :: Lens' RetryStatus Int
+ Himari.Prelude: rsPreviousDelayL :: Lens' RetryStatus (Maybe Int)
+ Himari.Prelude: simulatePolicy :: Monad m => Int -> RetryPolicyM m -> m [(Int, Maybe Int)]
+ Himari.Prelude: simulatePolicyPP :: Int -> RetryPolicyM IO -> IO ()
+ Himari.Prelude: skipAsyncExceptions :: forall (m :: Type -> Type). MonadIO m => [RetryStatus -> Handler m Bool]
+ Himari.Prelude: stepping :: MonadUnliftIO m => RetryPolicyM m -> [RetryStatus -> Handler m Bool] -> (RetryStatus -> m ()) -> (RetryStatus -> m a) -> RetryStatus -> m (Maybe a)
+ Himari.Prelude: toRetryAction :: Bool -> RetryAction
+ Himari.Prelude: type RetryPolicy = forall (m :: Type -> Type). Monad m => RetryPolicyM m
+ Himari.SafePrelude: LevelDebug :: LogLevel
+ Himari.SafePrelude: LevelError :: LogLevel
+ Himari.SafePrelude: LevelInfo :: LogLevel
+ Himari.SafePrelude: LevelOther :: Text -> LogLevel
+ Himari.SafePrelude: LevelWarn :: LogLevel
+ Himari.SafePrelude: Loc :: String -> String -> String -> CharPos -> CharPos -> Loc
+ Himari.SafePrelude: LoggingT :: ((Loc -> LogSource -> LogLevel -> LogStr -> IO ()) -> m a) -> LoggingT (m :: Type -> Type) a
+ Himari.SafePrelude: NoLoggingT :: m a -> NoLoggingT (m :: Type -> Type) a
+ Himari.SafePrelude: WriterLoggingT :: m (a, DList LogLine) -> WriterLoggingT (m :: Type -> Type) a
+ Himari.SafePrelude: [loc_end] :: Loc -> CharPos
+ Himari.SafePrelude: [loc_filename] :: Loc -> String
+ Himari.SafePrelude: [loc_module] :: Loc -> String
+ Himari.SafePrelude: [loc_package] :: Loc -> String
+ Himari.SafePrelude: [loc_start] :: Loc -> CharPos
+ Himari.SafePrelude: [runLoggingT] :: LoggingT (m :: Type -> Type) a -> (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) -> m a
+ Himari.SafePrelude: [runNoLoggingT] :: NoLoggingT (m :: Type -> Type) a -> m a
+ Himari.SafePrelude: [unWriterLoggingT] :: WriterLoggingT (m :: Type -> Type) a -> m (a, DList LogLine)
+ Himari.SafePrelude: askLoggerIO :: MonadLoggerIO m => m (Loc -> LogSource -> LogLevel -> LogStr -> IO ())
+ Himari.SafePrelude: class Monad m => MonadLogger (m :: Type -> Type)
+ Himari.SafePrelude: class (MonadLogger m, MonadIO m) => MonadLoggerIO (m :: Type -> Type)
+ Himari.SafePrelude: class ToLogStr msg
+ Himari.SafePrelude: data Loc
+ Himari.SafePrelude: data LogLevel
+ Himari.SafePrelude: data LogStr
+ Himari.SafePrelude: defaultLoc :: Loc
+ Himari.SafePrelude: defaultLogStr :: Loc -> LogSource -> LogLevel -> LogStr -> LogStr
+ Himari.SafePrelude: defaultOutput :: Handle -> Loc -> LogSource -> LogLevel -> LogStr -> IO ()
+ Himari.SafePrelude: execWriterLoggingT :: Functor m => WriterLoggingT m a -> m [LogLine]
+ Himari.SafePrelude: filterLogger :: forall (m :: Type -> Type) a. (LogSource -> LogLevel -> Bool) -> LoggingT m a -> LoggingT m a
+ Himari.SafePrelude: fromLogStr :: LogStr -> ByteString
+ Himari.SafePrelude: liftLoc :: Loc -> Q Exp
+ Himari.SafePrelude: logDebug :: Q Exp
+ Himari.SafePrelude: logDebugCS :: MonadLogger m => CallStack -> Text -> m ()
+ Himari.SafePrelude: logDebugN :: MonadLogger m => Text -> m ()
+ Himari.SafePrelude: logDebugNS :: MonadLogger m => LogSource -> Text -> m ()
+ Himari.SafePrelude: logDebugS :: Q Exp
+ Himari.SafePrelude: logDebugSH :: Q Exp
+ Himari.SafePrelude: logError :: Q Exp
+ Himari.SafePrelude: logErrorCS :: MonadLogger m => CallStack -> Text -> m ()
+ Himari.SafePrelude: logErrorN :: MonadLogger m => Text -> m ()
+ Himari.SafePrelude: logErrorNS :: MonadLogger m => LogSource -> Text -> m ()
+ Himari.SafePrelude: logErrorS :: Q Exp
+ Himari.SafePrelude: logErrorSH :: Q Exp
+ Himari.SafePrelude: logInfo :: Q Exp
+ Himari.SafePrelude: logInfoCS :: MonadLogger m => CallStack -> Text -> m ()
+ Himari.SafePrelude: logInfoN :: MonadLogger m => Text -> m ()
+ Himari.SafePrelude: logInfoNS :: MonadLogger m => LogSource -> Text -> m ()
+ Himari.SafePrelude: logInfoS :: Q Exp
+ Himari.SafePrelude: logInfoSH :: Q Exp
+ Himari.SafePrelude: logOther :: Text -> Q Exp
+ Himari.SafePrelude: logOtherCS :: MonadLogger m => CallStack -> LogLevel -> Text -> m ()
+ Himari.SafePrelude: logOtherN :: MonadLogger m => LogLevel -> Text -> m ()
+ Himari.SafePrelude: logOtherNS :: MonadLogger m => LogSource -> LogLevel -> Text -> m ()
+ Himari.SafePrelude: logOtherS :: Q Exp
+ Himari.SafePrelude: logOtherSH :: Text -> Q Exp
+ Himari.SafePrelude: logWarn :: Q Exp
+ Himari.SafePrelude: logWarnCS :: MonadLogger m => CallStack -> Text -> m ()
+ Himari.SafePrelude: logWarnN :: MonadLogger m => Text -> m ()
+ Himari.SafePrelude: logWarnNS :: MonadLogger m => LogSource -> Text -> m ()
+ Himari.SafePrelude: logWarnS :: Q Exp
+ Himari.SafePrelude: logWarnSH :: Q Exp
+ Himari.SafePrelude: logWithoutLoc :: (MonadLogger m, ToLogStr msg) => LogSource -> LogLevel -> msg -> m ()
+ Himari.SafePrelude: mapLoggingT :: (m a -> n b) -> LoggingT m a -> LoggingT n b
+ Himari.SafePrelude: mapNoLoggingT :: (m a -> n b) -> NoLoggingT m a -> NoLoggingT n b
+ Himari.SafePrelude: monadLoggerLog :: (MonadLogger m, ToLogStr msg) => Loc -> LogSource -> LogLevel -> msg -> m ()
+ Himari.SafePrelude: newtype LoggingT (m :: Type -> Type) a
+ Himari.SafePrelude: newtype NoLoggingT (m :: Type -> Type) a
+ Himari.SafePrelude: newtype WriterLoggingT (m :: Type -> Type) a
+ Himari.SafePrelude: runChanLoggingT :: MonadIO m => Chan LogLine -> LoggingT m a -> m a
+ Himari.SafePrelude: runFileLoggingT :: MonadBaseControl IO m => FilePath -> LoggingT m a -> m a
+ Himari.SafePrelude: runStderrLoggingT :: MonadIO m => LoggingT m a -> m a
+ Himari.SafePrelude: runStdoutLoggingT :: MonadIO m => LoggingT m a -> m a
+ Himari.SafePrelude: runWriterLoggingT :: Functor m => WriterLoggingT m a -> m (a, [LogLine])
+ Himari.SafePrelude: toLogStr :: ToLogStr msg => msg -> LogStr
+ Himari.SafePrelude: type LogLine = (Loc, LogSource, LogLevel, LogStr)
+ Himari.SafePrelude: type LogSource = Text
+ Himari.SafePrelude: unChanLoggingT :: (MonadLogger m, MonadIO m) => Chan LogLine -> m void
+ Himari.SafePrelude: withChannelLogger :: forall (m :: Type -> Type) a. (MonadBaseControl IO m, MonadIO m) => Int -> LoggingT m a -> LoggingT m a
Files
- .hlint.yaml +202/−202
- CHANGELOG.md +8/−0
- README.md +1/−1
- himari.cabal +16/−13
- test/Himari/CharSpec.hs +0/−220
- test/Himari/Env/SimpleSpec.hs +0/−110
- test/Himari/Prelude/FunctorSpec.hs +0/−41
- test/HlintBaseSpec.hs +0/−49
- test/HlintExtensionSpec.hs +0/−19
- test/HlintReexportSpec.hs +0/−241
- test/HlintRunner.hs +47/−25
- test/HlintUnliftioSpec.hs +0/−33
- test/Main.hs +3/−18
- test/Spec.hs +17/−0
- test/Spec/Himari/CharSpec.hs +208/−0
- test/Spec/Himari/Env/SimpleSpec.hs +97/−0
- test/Spec/Himari/Prelude/FunctorSpec.hs +41/−0
- test/Spec/HlintBaseSpec.hs +49/−0
- test/Spec/HlintExtensionSpec.hs +19/−0
- test/Spec/HlintReexportSpec.hs +259/−0
- test/Spec/HlintUnliftioSpec.hs +33/−0
- test/Spec/TitleSpec.hs +32/−0
- test/TitleSpec.hs +0/−32
.hlint.yaml view
@@ -11,37 +11,37 @@ # * このファイルをプロジェクトルートに .hlint.yaml としてコピー # * または .hlint.yaml から参照: - arguments: [--hint=path/to/this/.hlint.yaml] - arguments:- - "-XGHC2024"- - "-XApplicativeDo"- - "-XBlockArguments"- - "-XCPP"- - "-XDefaultSignatures"- - "-XDerivingVia"- - "-XDuplicateRecordFields"- - "-XFunctionalDependencies"- - "-XLexicalNegation"- - "-XLinearTypes"- - "-XMonadComprehensions"- - "-XMultiWayIf"- - "-XNegativeLiterals"- - "-XNoFieldSelectors"- - "-XNoImplicitPrelude"- - "-XOverloadedLabels"- - "-XOverloadedRecordDot"- - "-XOverloadedStrings"- - "-XParallelListComp"- - "-XPatternSynonyms"- - "-XQualifiedDo"- - "-XQuantifiedConstraints"- - "-XQuasiQuotes"- - "-XRecordWildCards"- - "-XRecursiveDo"- - "-XStrictData"- - "-XTemplateHaskell"- - "-XTypeData"- - "-XTypeFamilies"- - "-XTypeFamilyDependencies"- - "-XViewPatterns"+ - -XGHC2024+ - -XApplicativeDo+ - -XBlockArguments+ - -XCPP+ - -XDefaultSignatures+ - -XDerivingVia+ - -XDuplicateRecordFields+ - -XFunctionalDependencies+ - -XLexicalNegation+ - -XLinearTypes+ - -XMonadComprehensions+ - -XMultiWayIf+ - -XNegativeLiterals+ - -XNoFieldSelectors+ - -XNoImplicitPrelude+ - -XOverloadedLabels+ - -XOverloadedRecordDot+ - -XOverloadedStrings+ - -XParallelListComp+ - -XPatternSynonyms+ - -XQualifiedDo+ - -XQuantifiedConstraints+ - -XQuasiQuotes+ - -XRecordWildCards+ - -XRecursiveDo+ - -XStrictData+ - -XTemplateHaskell+ - -XTypeData+ - -XTypeFamilies+ - -XTypeFamilyDependencies+ - -XViewPatterns - group: enabled: true name: generalise@@ -50,10 +50,10 @@ name: dollar - group: enabled: true- name: "use-lens"+ name: use-lens - group: enabled: true- name: "use-th-quotes"+ name: use-th-quotes - functions: - message: Discards error info. Use eitherDecode instead to get error messages. name: Data.Aeson.decode@@ -69,30 +69,30 @@ within: [] - functions: - message: Deprecated alias since aeson 2.2.0.0. Use eitherDecode instead.- name: "Data.Aeson.decode'"+ name: Data.Aeson.decode' within: [] - message: Deprecated alias since aeson 2.2.0.0. Use eitherDecodeStrict instead.- name: "Data.Aeson.decodeStrict'"+ name: Data.Aeson.decodeStrict' within: [] - message: Deprecated alias since aeson 2.2.0.0. Use eitherDecodeFileStrict instead.- name: "Data.Aeson.decodeFileStrict'"+ name: Data.Aeson.decodeFileStrict' within: [] - functions: - message: Deprecated alias since aeson 2.2.0.0. Use eitherDecode instead.- name: "Data.Aeson.eitherDecode'"+ name: Data.Aeson.eitherDecode' within: [] - message: Deprecated alias since aeson 2.2.0.0. Use eitherDecodeStrict instead.- name: "Data.Aeson.eitherDecodeStrict'"+ name: Data.Aeson.eitherDecodeStrict' within: [] - message: Deprecated alias since aeson 2.2.0.0. Use eitherDecodeFileStrict instead.- name: "Data.Aeson.eitherDecodeFileStrict'"+ name: Data.Aeson.eitherDecodeFileStrict' within: [] - functions: - message: Deprecated alias since aeson 2.2.0.0. Use throwDecode instead.- name: "Data.Aeson.throwDecode'"+ name: Data.Aeson.throwDecode' within: [] - message: Deprecated alias since aeson 2.2.0.0. Use throwDecodeStrict instead.- name: "Data.Aeson.throwDecodeStrict'"+ name: Data.Aeson.throwDecodeStrict' within: [] - functions: - message: Discards error info. Use parseEither instead to get error messages.@@ -144,13 +144,13 @@ name: Data.ByteString.foldl1 within: [] - message: "Partial: throws on empty ByteString. Use foldl' with explicit initial value."- name: "Data.ByteString.foldl1'"+ name: Data.ByteString.foldl1' within: [] - message: "Partial: throws on empty ByteString. Use foldr with explicit initial value." name: Data.ByteString.foldr1 within: [] - message: "Partial: throws on empty ByteString. Use foldr' with explicit initial value."- name: "Data.ByteString.foldr1'"+ name: Data.ByteString.foldr1' within: [] - message: "Partial: throws on empty ByteString. Use fold with explicit initial value." name: Data.ByteString.maximum@@ -178,13 +178,13 @@ name: Data.ByteString.Char8.foldl1 within: [] - message: "Partial: throws on empty ByteString. Use foldl' with explicit initial value."- name: "Data.ByteString.Char8.foldl1'"+ name: Data.ByteString.Char8.foldl1' within: [] - message: "Partial: throws on empty ByteString. Use foldr with explicit initial value." name: Data.ByteString.Char8.foldr1 within: [] - message: "Partial: throws on empty ByteString. Use foldr' with explicit initial value."- name: "Data.ByteString.Char8.foldr1'"+ name: Data.ByteString.Char8.foldr1' within: [] - message: "Partial: throws on empty ByteString. Use fold with explicit initial value." name: Data.ByteString.Char8.maximum@@ -212,13 +212,13 @@ name: Data.ByteString.Lazy.foldl1 within: [] - message: "Partial: throws on empty ByteString. Use foldl' with explicit initial value."- name: "Data.ByteString.Lazy.foldl1'"+ name: Data.ByteString.Lazy.foldl1' within: [] - message: "Partial: throws on empty ByteString. Use foldr with explicit initial value." name: Data.ByteString.Lazy.foldr1 within: [] - message: "Partial: throws on empty ByteString. Use foldr' with explicit initial value."- name: "Data.ByteString.Lazy.foldr1'"+ name: Data.ByteString.Lazy.foldr1' within: [] - message: "Partial: throws on empty ByteString. Use fold with explicit initial value." name: Data.ByteString.Lazy.maximum@@ -249,13 +249,13 @@ name: Data.ByteString.Lazy.Char8.foldl1 within: [] - message: "Partial: throws on empty ByteString. Use foldl' with explicit initial value."- name: "Data.ByteString.Lazy.Char8.foldl1'"+ name: Data.ByteString.Lazy.Char8.foldl1' within: [] - message: "Partial: throws on empty ByteString. Use foldr with explicit initial value." name: Data.ByteString.Lazy.Char8.foldr1 within: [] - message: "Partial: throws on empty ByteString. Use foldr' with explicit initial value."- name: "Data.ByteString.Lazy.Char8.foldr1'"+ name: Data.ByteString.Lazy.Char8.foldr1' within: [] - message: "Partial: throws on empty ByteString. Use fold with explicit initial value." name: Data.ByteString.Lazy.Char8.maximum@@ -286,13 +286,13 @@ name: Data.ByteString.Short.foldl1 within: [] - message: "Partial: throws on empty ShortByteString. Use foldl' with explicit initial value."- name: "Data.ByteString.Short.foldl1'"+ name: Data.ByteString.Short.foldl1' within: [] - message: "Partial: throws on empty ShortByteString. Use foldr with explicit initial value." name: Data.ByteString.Short.foldr1 within: [] - message: "Partial: throws on empty ShortByteString. Use foldr' with explicit initial value."- name: "Data.ByteString.Short.foldr1'"+ name: Data.ByteString.Short.foldr1' within: [] - message: "Partial: throws on out-of-bounds. Use Data.ByteString.Short.indexMaybe or Data.ByteString.Short.(!?) instead" name: Data.ByteString.Short.index@@ -330,22 +330,22 @@ name: Data.Char.chr within: [] - functions:- - message: "Exceptions don't propagate to parent thread. Use async or withAsync from UnliftIO.Async instead."+ - message: Exceptions don't propagate to parent thread. Use async or withAsync from UnliftIO.Async instead. name: forkIO within: []- - message: "Exceptions don't propagate to parent thread. Use asyncBound or withAsyncBound from UnliftIO.Async instead."+ - message: Exceptions don't propagate to parent thread. Use asyncBound or withAsyncBound from UnliftIO.Async instead. name: forkOS within: []- - message: "Exceptions don't propagate to parent thread. Use asyncOn or withAsyncOn from UnliftIO.Async instead."+ - message: Exceptions don't propagate to parent thread. Use asyncOn or withAsyncOn from UnliftIO.Async instead. name: forkOn within: []- - message: "Exceptions don't propagate to parent thread. Use asyncWithUnmask or withAsyncWithUnmask from UnliftIO.Async instead."+ - message: Exceptions don't propagate to parent thread. Use asyncWithUnmask or withAsyncWithUnmask from UnliftIO.Async instead. name: forkIOWithUnmask within: []- - message: "Exceptions don't propagate to parent thread. Use asyncOnWithUnmask or withAsyncOnWithUnmask from UnliftIO.Async instead."+ - message: Exceptions don't propagate to parent thread. Use asyncOnWithUnmask or withAsyncOnWithUnmask from UnliftIO.Async instead. name: forkOnWithUnmask within: []- - message: "Deprecated and exceptions don't propagate to parent thread. Use asyncWithUnmask or withAsyncWithUnmask from UnliftIO.Async instead."+ - message: Deprecated and exceptions don't propagate to parent thread. Use asyncWithUnmask or withAsyncWithUnmask from UnliftIO.Async instead. name: forkWithUnmask within: [] - message: No automatic cancellation or exception handling. Use UnliftIO.Async instead.@@ -354,12 +354,12 @@ - message: Prefer structured cancellation with cancel or withAsync. Use UnliftIO.Async instead. name: killThread within: []- - message: "Almost impossible to use correctly. Consider typed-process or UnliftIO.Async."+ - message: Almost impossible to use correctly. Consider typed-process or UnliftIO.Async. name: forkProcess within: [] - functions:- - message: "Use Data.Map.lookup or Data.Map.!? instead"- name: "Data.Map.!"+ - message: Use Data.Map.lookup or Data.Map.!? instead+ name: Data.Map.! within: [] - message: "Partial: throws on empty map. Use Data.Map.lookupMin instead." name: Data.Map.findMin@@ -386,8 +386,8 @@ name: Data.Map.deleteFindMax within: [] - functions:- - message: "Use Data.Map.Strict.lookup or Data.Map.Strict.!? instead"- name: "Data.Map.Strict.!"+ - message: Use Data.Map.Strict.lookup or Data.Map.Strict.!? instead+ name: Data.Map.Strict.! within: [] - message: "Partial: throws on empty map. Use Data.Map.Strict.lookupMin instead." name: Data.Map.Strict.findMin@@ -414,8 +414,8 @@ name: Data.Map.Strict.deleteFindMax within: [] - functions:- - message: "Use Data.Map.Lazy.lookup or Data.Map.Lazy.!? instead"- name: "Data.Map.Lazy.!"+ - message: Use Data.Map.Lazy.lookup or Data.Map.Lazy.!? instead+ name: Data.Map.Lazy.! within: [] - message: "Partial: throws on empty map. Use Data.Map.Lazy.lookupMin instead." name: Data.Map.Lazy.findMin@@ -464,8 +464,8 @@ name: Data.Set.deleteFindMax within: [] - functions:- - message: "Use Data.IntMap.lookup or Data.IntMap.!? instead"- name: "Data.IntMap.!"+ - message: Use Data.IntMap.lookup or Data.IntMap.!? instead+ name: Data.IntMap.! within: [] - message: "Partial: throws on empty map. Use Data.IntMap.lookupMin instead." name: Data.IntMap.findMin@@ -480,8 +480,8 @@ name: Data.IntMap.deleteFindMax within: [] - functions:- - message: "Use Data.IntMap.Strict.lookup or Data.IntMap.Strict.!? instead"- name: "Data.IntMap.Strict.!"+ - message: Use Data.IntMap.Strict.lookup or Data.IntMap.Strict.!? instead+ name: Data.IntMap.Strict.! within: [] - message: "Partial: throws on empty map. Use Data.IntMap.Strict.lookupMin instead." name: Data.IntMap.Strict.findMin@@ -496,8 +496,8 @@ name: Data.IntMap.Strict.deleteFindMax within: [] - functions:- - message: "Use Data.IntMap.Lazy.lookup or Data.IntMap.Lazy.!? instead"- name: "Data.IntMap.Lazy.!"+ - message: Use Data.IntMap.Lazy.lookup or Data.IntMap.Lazy.!? instead+ name: Data.IntMap.Lazy.! within: [] - message: "Partial: throws on empty map. Use Data.IntMap.Lazy.lookupMin instead." name: Data.IntMap.Lazy.findMin@@ -543,7 +543,7 @@ name: Data.Text.Lazy.Encoding.decodeUtf8 within: [] - functions:- - message: "Don't throw in pure code. Use throwM in MonadThrow context."+ - message: Don't throw in pure code. Use throwM in MonadThrow context. name: throw within: [] - message: Use typed exceptions with throwM instead of throwString.@@ -552,7 +552,7 @@ - message: Use typed exceptions with throwM instead of throwIO. name: throwIO within: []- - message: "Avoid in production code. For development placeholders, consider typed holes instead."+ - message: Avoid in production code. For development placeholders, consider typed holes instead. name: error within: [] - message: Remember to implement before release. Consider typed holes for better error messages.@@ -561,19 +561,19 @@ - message: Use proper error handling name: errorWithoutStackTrace within: []- - message: "Deprecated. Use error instead, which now includes stack traces."+ - message: Deprecated. Use error instead, which now includes stack traces. name: errorWithStackTrace within: [] - extensions:- - message: "Defers ambiguity errors to call sites, making debugging harder"+ - message: Defers ambiguity errors to call sites, making debugging harder name: - AllowAmbiguousTypes within: []- - message: "Defers type errors to runtime, defeating Haskell's type safety"+ - message: Defers type errors to runtime, defeating Haskell's type safety name: - DeferTypeErrors within: []- - message: "Causes unexpected type defaulting (e.g., show.read defaults to ())"+ - message: Causes unexpected type defaulting (e.g., show.read defaults to ()) name: - ExtendedDefaultRules within: []@@ -581,7 +581,7 @@ name: - ImpredicativeTypes within: []- - message: "Makes instance selection non-deterministic and order-dependent"+ - message: Makes instance selection non-deterministic and order-dependent name: - IncoherentInstances within: []@@ -589,15 +589,15 @@ name: - LiberalTypeSynonyms within: []- - message: "Deprecated since GHC 7.10, use OVERLAPPING pragma if truly needed"+ - message: Deprecated since GHC 7.10, use OVERLAPPING pragma if truly needed name: - OverlappingInstances within: []- - message: "Changes do/if-then-else semantics, breaks deriving and TH"+ - message: Changes do/if-then-else semantics, breaks deriving and TH name: - RebindableSyntax within: []- - message: "Can cause type checker non-termination or stack overflow"+ - message: Can cause type checker non-termination or stack overflow name: - UndecidableSuperClasses within: []@@ -612,10 +612,10 @@ within: [] - functions: - message: "Partial: throws on empty Fold. Use (^?) instead."- name: "Control.Lens.Fold.^?!"+ name: Control.Lens.Fold.^?! within: [] - message: "Partial: throws on empty Fold. Use (^@?) instead."- name: "Control.Lens.Fold.^@?!"+ name: Control.Lens.Fold.^@?! within: [] - message: "Partial: throws on 0 or >1 elements. Consider using (^?) or ensure exactly 1 element." name: Control.Lens.Traversal.singular@@ -721,70 +721,70 @@ name: showBin within: [] - functions:- - message: "O(n^2) complexity. Use ordNub or nubOrd instead."+ - message: O(n^2) complexity. Use ordNub or nubOrd instead. name: nub within: []- - message: "Lazy accumulator causes space leaks. Use foldl' instead."+ - message: Lazy accumulator causes space leaks. Use foldl' instead. name: foldl within: []- - message: "O(n) stack space. Use length with explicit conversion."+ - message: O(n) stack space. Use length with explicit conversion. name: genericLength within: [] - hint: lhs: trace- note: "pTrace* provides pretty-printed output for easier debugging"+ note: pTrace* provides pretty-printed output for easier debugging rhs: pTrace - hint: lhs: traceId- note: "pTrace* provides pretty-printed output for easier debugging"+ note: pTrace* provides pretty-printed output for easier debugging rhs: pTraceId - hint: lhs: traceShow- note: "pTrace* provides pretty-printed output for easier debugging"+ note: pTrace* provides pretty-printed output for easier debugging rhs: pTraceShow - hint: lhs: traceShowId- note: "pTrace* provides pretty-printed output for easier debugging"+ note: pTrace* provides pretty-printed output for easier debugging rhs: pTraceShowId - hint: lhs: traceWith- note: "pTrace* provides pretty-printed output for easier debugging"+ note: pTrace* provides pretty-printed output for easier debugging rhs: pTraceWith - hint: lhs: traceShowWith- note: "pTrace* provides pretty-printed output for easier debugging"+ note: pTrace* provides pretty-printed output for easier debugging rhs: pTraceShowWith - hint: lhs: traceStack- note: "pTrace* provides pretty-printed output for easier debugging"+ note: pTrace* provides pretty-printed output for easier debugging rhs: pTraceStack - hint: lhs: traceIO- note: "pTrace* provides pretty-printed output for easier debugging"+ note: pTrace* provides pretty-printed output for easier debugging rhs: pTraceIO - hint: lhs: traceM- note: "pTrace* provides pretty-printed output for easier debugging"+ note: pTrace* provides pretty-printed output for easier debugging rhs: pTraceM - hint: lhs: traceShowM- note: "pTrace* provides pretty-printed output for easier debugging"+ note: pTrace* provides pretty-printed output for easier debugging rhs: pTraceShowM - hint: lhs: traceEvent- note: "pTrace* provides pretty-printed output for easier debugging"+ note: pTrace* provides pretty-printed output for easier debugging rhs: pTraceEvent - hint: lhs: traceEventIO- note: "pTrace* provides pretty-printed output for easier debugging"+ note: pTrace* provides pretty-printed output for easier debugging rhs: pTraceEventIO - hint: lhs: traceMarker- note: "pTrace* provides pretty-printed output for easier debugging"+ note: pTrace* provides pretty-printed output for easier debugging rhs: pTraceMarker - hint: lhs: traceMarkerIO- note: "pTrace* provides pretty-printed output for easier debugging"+ note: pTrace* provides pretty-printed output for easier debugging rhs: pTraceMarkerIO - functions: - message: Unsafe primitive state token conversion. Use safe alternatives.@@ -833,7 +833,7 @@ - as: TL importStyle: explicitOrQualified name: Data.Text.Lazy- - message: "Data.Map is a re-export of Data.Map.Lazy. Use Data.Map.Strict or Data.Map.Lazy directly."+ - message: Data.Map is a re-export of Data.Map.Lazy. Use Data.Map.Strict or Data.Map.Lazy directly. name: Data.Map within: [] - as: Map@@ -842,7 +842,7 @@ - as: MapL importStyle: explicitOrQualified name: Data.Map.Lazy- - message: "Data.IntMap is a re-export of Data.IntMap.Lazy. Use Data.IntMap.Strict or Data.IntMap.Lazy directly."+ - message: Data.IntMap is a re-export of Data.IntMap.Lazy. Use Data.IntMap.Strict or Data.IntMap.Lazy directly. name: Data.IntMap within: [] - as: IntMap@@ -959,7 +959,7 @@ name: Himari.SafePrelude.last within: [] - message: "Partial: throws on out-of-bounds. Use atMay or atDef from Safe instead."- name: "Data.List.!!"+ name: Data.List.!! within: [] - message: "Partial: throws on empty list. Use cycleMay or cycleDef from Safe instead." name: Data.List.cycle@@ -1001,7 +1001,7 @@ name: Data.List.foldl1 within: [] - message: "Partial: throws on empty list. Use foldl1May' from Safe instead."- name: "Data.List.foldl1'"+ name: Data.List.foldl1' within: [] - message: "Partial: throws on empty list. Use foldr1May from Safe instead." name: Data.List.foldr1@@ -1183,7 +1183,7 @@ within: [] - functions: - message: "Partial: throws on out-of-bounds. Use atMay or atDef from Safe with toList instead."- name: "Data.List.NonEmpty.!!"+ name: Data.List.NonEmpty.!! within: [] - message: "Partial: throws on empty list. Use nonEmpty instead." name: Data.List.NonEmpty.fromList@@ -1249,7 +1249,7 @@ name: Safe.foldl1Note within: [] - message: "Partial: throws on empty list. Use foldl1May' instead."- name: "Safe.foldl1Note'"+ name: Safe.foldl1Note' within: [] - message: "Partial: throws on empty list. Use scanr1May or scanr1Def instead." name: Safe.scanr1Note@@ -1389,64 +1389,64 @@ - message: Encoding depends on LANG env. Use Text or ByteString. name: Himari.SafePrelude.getLine within: []- - message: "Lazy IO + env-dependent encoding. Use strict Text or ByteString."+ - message: Lazy IO + env-dependent encoding. Use strict Text or ByteString. name: System.IO.getContents within: []- - message: "Lazy IO + env-dependent encoding. Use strict Text or ByteString."+ - message: Lazy IO + env-dependent encoding. Use strict Text or ByteString. name: Himari.getContents within: []- - message: "Lazy IO + env-dependent encoding. Use strict Text or ByteString."+ - message: Lazy IO + env-dependent encoding. Use strict Text or ByteString. name: Himari.Prelude.getContents within: []- - message: "Lazy IO + env-dependent encoding. Use strict Text or ByteString."+ - message: Lazy IO + env-dependent encoding. Use strict Text or ByteString. name: Himari.SafePrelude.getContents within: []- - message: "Lazy IO + env-dependent encoding. Use Data.Text.IO.readFile or Data.ByteString.readFile."+ - message: Lazy IO + env-dependent encoding. Use Data.Text.IO.readFile or Data.ByteString.readFile. name: System.IO.readFile within: []- - message: "Lazy IO + env-dependent encoding. Use Data.Text.IO.readFile or Data.ByteString.readFile."+ - message: Lazy IO + env-dependent encoding. Use Data.Text.IO.readFile or Data.ByteString.readFile. name: Himari.readFile within: []- - message: "Lazy IO + env-dependent encoding. Use Data.Text.IO.readFile or Data.ByteString.readFile."+ - message: Lazy IO + env-dependent encoding. Use Data.Text.IO.readFile or Data.ByteString.readFile. name: Himari.Prelude.readFile within: []- - message: "Lazy IO + env-dependent encoding. Use Data.Text.IO.readFile or Data.ByteString.readFile."+ - message: Lazy IO + env-dependent encoding. Use Data.Text.IO.readFile or Data.ByteString.readFile. name: Himari.SafePrelude.readFile within: []- - message: "Lazy IO + env-dependent encoding."+ - message: Lazy IO + env-dependent encoding. name: System.IO.interact within: []- - message: "Lazy IO + env-dependent encoding."+ - message: Lazy IO + env-dependent encoding. name: Himari.interact within: []- - message: "Lazy IO + env-dependent encoding."+ - message: Lazy IO + env-dependent encoding. name: Himari.Prelude.interact within: []- - message: "Lazy IO + env-dependent encoding."+ - message: Lazy IO + env-dependent encoding. name: Himari.SafePrelude.interact within: []- - message: "Env-dependent + partial (uses read)."+ - message: Env-dependent + partial (uses read). name: System.IO.readIO within: []- - message: "Env-dependent + partial (uses read)."+ - message: Env-dependent + partial (uses read). name: Himari.readIO within: []- - message: "Env-dependent + partial (uses read)."+ - message: Env-dependent + partial (uses read). name: Himari.Prelude.readIO within: []- - message: "Env-dependent + partial (uses read)."+ - message: Env-dependent + partial (uses read). name: Himari.SafePrelude.readIO within: []- - message: "Env-dependent + partial (uses read)."+ - message: Env-dependent + partial (uses read). name: System.IO.readLn within: []- - message: "Env-dependent + partial (uses read)."+ - message: Env-dependent + partial (uses read). name: Himari.readLn within: []- - message: "Env-dependent + partial (uses read)."+ - message: Env-dependent + partial (uses read). name: Himari.Prelude.readLn within: []- - message: "Env-dependent + partial (uses read)."+ - message: Env-dependent + partial (uses read). name: Himari.SafePrelude.readLn within: [] - message: Encoding depends on LANG env. Use Text or ByteString.@@ -1497,28 +1497,28 @@ - message: Encoding depends on LANG env. Use Text or ByteString. name: Himari.SafePrelude.print within: []- - message: "Env-dependent encoding. Use Data.Text.IO.writeFile or Data.ByteString.writeFile."+ - message: Env-dependent encoding. Use Data.Text.IO.writeFile or Data.ByteString.writeFile. name: System.IO.writeFile within: []- - message: "Env-dependent encoding. Use Data.Text.IO.writeFile or Data.ByteString.writeFile."+ - message: Env-dependent encoding. Use Data.Text.IO.writeFile or Data.ByteString.writeFile. name: Himari.writeFile within: []- - message: "Env-dependent encoding. Use Data.Text.IO.writeFile or Data.ByteString.writeFile."+ - message: Env-dependent encoding. Use Data.Text.IO.writeFile or Data.ByteString.writeFile. name: Himari.Prelude.writeFile within: []- - message: "Env-dependent encoding. Use Data.Text.IO.writeFile or Data.ByteString.writeFile."+ - message: Env-dependent encoding. Use Data.Text.IO.writeFile or Data.ByteString.writeFile. name: Himari.SafePrelude.writeFile within: []- - message: "Env-dependent encoding. Use Data.Text.IO.appendFile or Data.ByteString.appendFile."+ - message: Env-dependent encoding. Use Data.Text.IO.appendFile or Data.ByteString.appendFile. name: System.IO.appendFile within: []- - message: "Env-dependent encoding. Use Data.Text.IO.appendFile or Data.ByteString.appendFile."+ - message: Env-dependent encoding. Use Data.Text.IO.appendFile or Data.ByteString.appendFile. name: Himari.appendFile within: []- - message: "Env-dependent encoding. Use Data.Text.IO.appendFile or Data.ByteString.appendFile."+ - message: Env-dependent encoding. Use Data.Text.IO.appendFile or Data.ByteString.appendFile. name: Himari.Prelude.appendFile within: []- - message: "Env-dependent encoding. Use Data.Text.IO.appendFile or Data.ByteString.appendFile."+ - message: Env-dependent encoding. Use Data.Text.IO.appendFile or Data.ByteString.appendFile. name: Himari.SafePrelude.appendFile within: [] - functions:@@ -1538,7 +1538,7 @@ name: Data.Text.foldl1 within: [] - message: "Partial: throws on empty Text. Use foldl' with explicit initial value."- name: "Data.Text.foldl1'"+ name: Data.Text.foldl1' within: [] - message: "Partial: throws on empty Text. Use foldr with explicit initial value." name: Data.Text.foldr1@@ -1569,7 +1569,7 @@ name: Data.Text.Lazy.foldl1 within: [] - message: "Partial: throws on empty Text. Use foldl' with explicit initial value."- name: "Data.Text.Lazy.foldl1'"+ name: Data.Text.Lazy.foldl1' within: [] - message: "Partial: throws on empty Text. Use foldr with explicit initial value." name: Data.Text.Lazy.foldr1@@ -1600,37 +1600,37 @@ name: Data.Text.Unsafe.dropWord8 within: [] - functions:- - message: "Use System.Process.Typed.runProcess_ instead for type-safe process execution."+ - message: Use System.Process.Typed.runProcess_ instead for type-safe process execution. name: System.Process.callProcess within: []- - message: "Use System.Process.Typed.runProcess_ with shell instead for type-safe process execution."+ - message: Use System.Process.Typed.runProcess_ with shell instead for type-safe process execution. name: System.Process.callCommand within: []- - message: "Use System.Process.Typed.startProcess instead for type-safe process execution."+ - message: Use System.Process.Typed.startProcess instead for type-safe process execution. name: System.Process.spawnProcess within: []- - message: "Use System.Process.Typed.startProcess with shell instead for type-safe process execution."+ - message: Use System.Process.Typed.startProcess with shell instead for type-safe process execution. name: System.Process.spawnCommand within: []- - message: "Use System.Process.Typed.startProcess instead for type-safe process execution."+ - message: Use System.Process.Typed.startProcess instead for type-safe process execution. name: System.Process.createProcess within: []- - message: "Use System.Process.Typed.startProcess instead for type-safe process execution."+ - message: Use System.Process.Typed.startProcess instead for type-safe process execution. name: System.Process.createProcess_ within: []- - message: "Use System.Process.Typed.stopProcess instead for type-safe process cleanup."+ - message: Use System.Process.Typed.stopProcess instead for type-safe process cleanup. name: System.Process.cleanupProcess within: []- - message: "Use System.Process.Typed.readProcessStdout instead for type-safe output capture."+ - message: Use System.Process.Typed.readProcessStdout instead for type-safe output capture. name: System.Process.readProcess within: []- - message: "Use System.Process.Typed.readProcess instead for type-safe output capture."+ - message: Use System.Process.Typed.readProcess instead for type-safe output capture. name: System.Process.readProcessWithExitCode within: []- - message: "Use System.Process.Typed.readProcessStdout instead for type-safe output capture."+ - message: Use System.Process.Typed.readProcessStdout instead for type-safe output capture. name: System.Process.readCreateProcess within: []- - message: "Use System.Process.Typed.readProcess instead for type-safe output capture."+ - message: Use System.Process.Typed.readProcess instead for type-safe output capture. name: System.Process.readCreateProcessWithExitCode within: [] - message: Use System.Process.Typed.waitExitCode instead for MonadIO support.@@ -1645,10 +1645,10 @@ - message: Consider using System.Process.Typed with setCreateGroup for process group management. name: System.Process.interruptProcessGroupOf within: []- - message: "Use System.Process.Typed.runProcess with shell instead for type-safe process execution."+ - message: Use System.Process.Typed.runProcess with shell instead for type-safe process execution. name: System.Process.runCommand within: []- - message: "Use System.Process.Typed.runProcess instead for type-safe process execution."+ - message: Use System.Process.Typed.runProcess instead for type-safe process execution. name: System.Process.runProcess within: [] - message: Use System.Process.Typed.startProcess with shell and createPipe instead.@@ -1657,16 +1657,16 @@ - message: Use System.Process.Typed.startProcess with createPipe instead. name: System.Process.runInteractiveProcess within: []- - message: "Use System.Process.Typed.runProcess with shell instead for type-safe process execution."+ - message: Use System.Process.Typed.runProcess with shell instead for type-safe process execution. name: System.Process.system within: []- - message: "Use System.Process.Typed.runProcess instead for type-safe process execution."+ - message: Use System.Process.Typed.runProcess instead for type-safe process execution. name: System.Process.rawSystem within: []- - message: "Use System.Process.Typed.proc instead for type-safe ProcessConfig."+ - message: Use System.Process.Typed.proc instead for type-safe ProcessConfig. name: System.Process.proc within: []- - message: "Use System.Process.Typed.shell instead for type-safe ProcessConfig."+ - message: Use System.Process.Typed.shell instead for type-safe ProcessConfig. name: System.Process.shell within: [] - message: Use System.Process.Typed.withProcessWait or withProcessTerm instead for MonadUnliftIO support.@@ -2005,14 +2005,14 @@ - message: Use UnliftIO.IORef.modifyIORef instead for MonadIO support. name: Data.IORef.modifyIORef within: []- - message: "Use UnliftIO.IORef.modifyIORef' instead for MonadIO support."- name: "Data.IORef.modifyIORef'"+ - message: Use UnliftIO.IORef.modifyIORef' instead for MonadIO support.+ name: Data.IORef.modifyIORef' within: [] - message: Use UnliftIO.IORef.atomicModifyIORef instead for MonadIO support. name: Data.IORef.atomicModifyIORef within: []- - message: "Use UnliftIO.IORef.atomicModifyIORef' instead for MonadIO support."- name: "Data.IORef.atomicModifyIORef'"+ - message: Use UnliftIO.IORef.atomicModifyIORef' instead for MonadIO support.+ name: Data.IORef.atomicModifyIORef' within: [] - message: Use UnliftIO.IORef.mkWeakIORef instead for MonadIO support. name: Data.IORef.mkWeakIORef@@ -2629,11 +2629,11 @@ within: [] - functions: - message: "Partial: throws on missing key. Use Data.HashMap.Strict.lookup or Data.HashMap.Strict.!? instead"- name: "Data.HashMap.Strict.!"+ name: Data.HashMap.Strict.! within: [] - functions: - message: "Partial: throws on missing key. Use Data.HashMap.Lazy.lookup or Data.HashMap.Lazy.!? instead"- name: "Data.HashMap.Lazy.!"+ name: Data.HashMap.Lazy.! within: [] - functions: - message: Breaks type safety. Only for very specific use cases.@@ -2653,7 +2653,7 @@ within: [] - functions: - message: "Partial: throws on out-of-bounds. Use (!?) for safe indexing."- name: "Data.Vector.!"+ name: Data.Vector.! within: [] - message: "Partial: throws on empty vector. Use uncons or (!?) 0 instead." name: Data.Vector.head@@ -2701,13 +2701,13 @@ name: Data.Vector.foldl1 within: [] - message: "Partial: throws on empty vector. Use foldl' with explicit initial value."- name: "Data.Vector.foldl1'"+ name: Data.Vector.foldl1' within: [] - message: "Partial: throws on empty vector. Use foldr with explicit initial value." name: Data.Vector.foldr1 within: [] - message: "Partial: throws on empty vector. Use foldr' with explicit initial value."- name: "Data.Vector.foldr1'"+ name: Data.Vector.foldr1' within: [] - message: "Partial: throws on empty vector. Use fold with explicit initial value." name: Data.Vector.maximum@@ -2737,28 +2737,28 @@ name: Data.Vector.fold1M within: [] - message: "Partial: throws on empty vector. Use foldM' with explicit initial value."- name: "Data.Vector.fold1M'"+ name: Data.Vector.fold1M' within: [] - message: "Partial: throws on empty vector. Use foldM_ with explicit initial value." name: Data.Vector.fold1M_ within: [] - message: "Partial: throws on empty vector. Use foldM'_ with explicit initial value."- name: "Data.Vector.fold1M'_"+ name: Data.Vector.fold1M'_ within: [] - message: "Partial: throws on empty vector. Use scanl with explicit initial value." name: Data.Vector.scanl1 within: [] - message: "Partial: throws on empty vector. Use scanl' with explicit initial value."- name: "Data.Vector.scanl1'"+ name: Data.Vector.scanl1' within: [] - message: "Partial: throws on empty vector. Use scanr with explicit initial value." name: Data.Vector.scanr1 within: [] - message: "Partial: throws on empty vector. Use scanr' with explicit initial value."- name: "Data.Vector.scanr1'"+ name: Data.Vector.scanr1' within: [] - message: "Partial: throws on out-of-bounds. Use (!?) for safe indexing."- name: "Data.Vector.Generic.!"+ name: Data.Vector.Generic.! within: [] - message: "Partial: throws on empty vector. Use uncons or (!?) 0 instead." name: Data.Vector.Generic.head@@ -2806,13 +2806,13 @@ name: Data.Vector.Generic.foldl1 within: [] - message: "Partial: throws on empty vector. Use foldl' with explicit initial value."- name: "Data.Vector.Generic.foldl1'"+ name: Data.Vector.Generic.foldl1' within: [] - message: "Partial: throws on empty vector. Use foldr with explicit initial value." name: Data.Vector.Generic.foldr1 within: [] - message: "Partial: throws on empty vector. Use foldr' with explicit initial value."- name: "Data.Vector.Generic.foldr1'"+ name: Data.Vector.Generic.foldr1' within: [] - message: "Partial: throws on empty vector. Use fold with explicit initial value." name: Data.Vector.Generic.maximum@@ -2842,28 +2842,28 @@ name: Data.Vector.Generic.fold1M within: [] - message: "Partial: throws on empty vector. Use foldM' with explicit initial value."- name: "Data.Vector.Generic.fold1M'"+ name: Data.Vector.Generic.fold1M' within: [] - message: "Partial: throws on empty vector. Use foldM_ with explicit initial value." name: Data.Vector.Generic.fold1M_ within: [] - message: "Partial: throws on empty vector. Use foldM'_ with explicit initial value."- name: "Data.Vector.Generic.fold1M'_"+ name: Data.Vector.Generic.fold1M'_ within: [] - message: "Partial: throws on empty vector. Use scanl with explicit initial value." name: Data.Vector.Generic.scanl1 within: [] - message: "Partial: throws on empty vector. Use scanl' with explicit initial value."- name: "Data.Vector.Generic.scanl1'"+ name: Data.Vector.Generic.scanl1' within: [] - message: "Partial: throws on empty vector. Use scanr with explicit initial value." name: Data.Vector.Generic.scanr1 within: [] - message: "Partial: throws on empty vector. Use scanr' with explicit initial value."- name: "Data.Vector.Generic.scanr1'"+ name: Data.Vector.Generic.scanr1' within: [] - message: "Partial: throws on out-of-bounds. Use (!?) for safe indexing."- name: "Data.Vector.Primitive.!"+ name: Data.Vector.Primitive.! within: [] - message: "Partial: throws on empty vector. Use uncons or (!?) 0 instead." name: Data.Vector.Primitive.head@@ -2911,13 +2911,13 @@ name: Data.Vector.Primitive.foldl1 within: [] - message: "Partial: throws on empty vector. Use foldl' with explicit initial value."- name: "Data.Vector.Primitive.foldl1'"+ name: Data.Vector.Primitive.foldl1' within: [] - message: "Partial: throws on empty vector. Use foldr with explicit initial value." name: Data.Vector.Primitive.foldr1 within: [] - message: "Partial: throws on empty vector. Use foldr' with explicit initial value."- name: "Data.Vector.Primitive.foldr1'"+ name: Data.Vector.Primitive.foldr1' within: [] - message: "Partial: throws on empty vector. Use fold with explicit initial value." name: Data.Vector.Primitive.maximum@@ -2947,28 +2947,28 @@ name: Data.Vector.Primitive.fold1M within: [] - message: "Partial: throws on empty vector. Use foldM' with explicit initial value."- name: "Data.Vector.Primitive.fold1M'"+ name: Data.Vector.Primitive.fold1M' within: [] - message: "Partial: throws on empty vector. Use foldM_ with explicit initial value." name: Data.Vector.Primitive.fold1M_ within: [] - message: "Partial: throws on empty vector. Use foldM'_ with explicit initial value."- name: "Data.Vector.Primitive.fold1M'_"+ name: Data.Vector.Primitive.fold1M'_ within: [] - message: "Partial: throws on empty vector. Use scanl with explicit initial value." name: Data.Vector.Primitive.scanl1 within: [] - message: "Partial: throws on empty vector. Use scanl' with explicit initial value."- name: "Data.Vector.Primitive.scanl1'"+ name: Data.Vector.Primitive.scanl1' within: [] - message: "Partial: throws on empty vector. Use scanr with explicit initial value." name: Data.Vector.Primitive.scanr1 within: [] - message: "Partial: throws on empty vector. Use scanr' with explicit initial value."- name: "Data.Vector.Primitive.scanr1'"+ name: Data.Vector.Primitive.scanr1' within: [] - message: "Partial: throws on out-of-bounds. Use (!?) for safe indexing."- name: "Data.Vector.Storable.!"+ name: Data.Vector.Storable.! within: [] - message: "Partial: throws on empty vector. Use uncons or (!?) 0 instead." name: Data.Vector.Storable.head@@ -3016,13 +3016,13 @@ name: Data.Vector.Storable.foldl1 within: [] - message: "Partial: throws on empty vector. Use foldl' with explicit initial value."- name: "Data.Vector.Storable.foldl1'"+ name: Data.Vector.Storable.foldl1' within: [] - message: "Partial: throws on empty vector. Use foldr with explicit initial value." name: Data.Vector.Storable.foldr1 within: [] - message: "Partial: throws on empty vector. Use foldr' with explicit initial value."- name: "Data.Vector.Storable.foldr1'"+ name: Data.Vector.Storable.foldr1' within: [] - message: "Partial: throws on empty vector. Use fold with explicit initial value." name: Data.Vector.Storable.maximum@@ -3052,28 +3052,28 @@ name: Data.Vector.Storable.fold1M within: [] - message: "Partial: throws on empty vector. Use foldM' with explicit initial value."- name: "Data.Vector.Storable.fold1M'"+ name: Data.Vector.Storable.fold1M' within: [] - message: "Partial: throws on empty vector. Use foldM_ with explicit initial value." name: Data.Vector.Storable.fold1M_ within: [] - message: "Partial: throws on empty vector. Use foldM'_ with explicit initial value."- name: "Data.Vector.Storable.fold1M'_"+ name: Data.Vector.Storable.fold1M'_ within: [] - message: "Partial: throws on empty vector. Use scanl with explicit initial value." name: Data.Vector.Storable.scanl1 within: [] - message: "Partial: throws on empty vector. Use scanl' with explicit initial value."- name: "Data.Vector.Storable.scanl1'"+ name: Data.Vector.Storable.scanl1' within: [] - message: "Partial: throws on empty vector. Use scanr with explicit initial value." name: Data.Vector.Storable.scanr1 within: [] - message: "Partial: throws on empty vector. Use scanr' with explicit initial value."- name: "Data.Vector.Storable.scanr1'"+ name: Data.Vector.Storable.scanr1' within: [] - message: "Partial: throws on out-of-bounds. Use (!?) for safe indexing."- name: "Data.Vector.Strict.!"+ name: Data.Vector.Strict.! within: [] - message: "Partial: throws on empty vector. Use uncons or (!?) 0 instead." name: Data.Vector.Strict.head@@ -3121,13 +3121,13 @@ name: Data.Vector.Strict.foldl1 within: [] - message: "Partial: throws on empty vector. Use foldl' with explicit initial value."- name: "Data.Vector.Strict.foldl1'"+ name: Data.Vector.Strict.foldl1' within: [] - message: "Partial: throws on empty vector. Use foldr with explicit initial value." name: Data.Vector.Strict.foldr1 within: [] - message: "Partial: throws on empty vector. Use foldr' with explicit initial value."- name: "Data.Vector.Strict.foldr1'"+ name: Data.Vector.Strict.foldr1' within: [] - message: "Partial: throws on empty vector. Use fold with explicit initial value." name: Data.Vector.Strict.maximum@@ -3157,28 +3157,28 @@ name: Data.Vector.Strict.fold1M within: [] - message: "Partial: throws on empty vector. Use foldM' with explicit initial value."- name: "Data.Vector.Strict.fold1M'"+ name: Data.Vector.Strict.fold1M' within: [] - message: "Partial: throws on empty vector. Use foldM_ with explicit initial value." name: Data.Vector.Strict.fold1M_ within: [] - message: "Partial: throws on empty vector. Use foldM'_ with explicit initial value."- name: "Data.Vector.Strict.fold1M'_"+ name: Data.Vector.Strict.fold1M'_ within: [] - message: "Partial: throws on empty vector. Use scanl with explicit initial value." name: Data.Vector.Strict.scanl1 within: [] - message: "Partial: throws on empty vector. Use scanl' with explicit initial value."- name: "Data.Vector.Strict.scanl1'"+ name: Data.Vector.Strict.scanl1' within: [] - message: "Partial: throws on empty vector. Use scanr with explicit initial value." name: Data.Vector.Strict.scanr1 within: [] - message: "Partial: throws on empty vector. Use scanr' with explicit initial value."- name: "Data.Vector.Strict.scanr1'"+ name: Data.Vector.Strict.scanr1' within: [] - message: "Partial: throws on out-of-bounds. Use (!?) for safe indexing."- name: "Data.Vector.Unboxed.!"+ name: Data.Vector.Unboxed.! within: [] - message: "Partial: throws on empty vector. Use uncons or (!?) 0 instead." name: Data.Vector.Unboxed.head@@ -3226,13 +3226,13 @@ name: Data.Vector.Unboxed.foldl1 within: [] - message: "Partial: throws on empty vector. Use foldl' with explicit initial value."- name: "Data.Vector.Unboxed.foldl1'"+ name: Data.Vector.Unboxed.foldl1' within: [] - message: "Partial: throws on empty vector. Use foldr with explicit initial value." name: Data.Vector.Unboxed.foldr1 within: [] - message: "Partial: throws on empty vector. Use foldr' with explicit initial value."- name: "Data.Vector.Unboxed.foldr1'"+ name: Data.Vector.Unboxed.foldr1' within: [] - message: "Partial: throws on empty vector. Use fold with explicit initial value." name: Data.Vector.Unboxed.maximum@@ -3262,25 +3262,25 @@ name: Data.Vector.Unboxed.fold1M within: [] - message: "Partial: throws on empty vector. Use foldM' with explicit initial value."- name: "Data.Vector.Unboxed.fold1M'"+ name: Data.Vector.Unboxed.fold1M' within: [] - message: "Partial: throws on empty vector. Use foldM_ with explicit initial value." name: Data.Vector.Unboxed.fold1M_ within: [] - message: "Partial: throws on empty vector. Use foldM'_ with explicit initial value."- name: "Data.Vector.Unboxed.fold1M'_"+ name: Data.Vector.Unboxed.fold1M'_ within: [] - message: "Partial: throws on empty vector. Use scanl with explicit initial value." name: Data.Vector.Unboxed.scanl1 within: [] - message: "Partial: throws on empty vector. Use scanl' with explicit initial value."- name: "Data.Vector.Unboxed.scanl1'"+ name: Data.Vector.Unboxed.scanl1' within: [] - message: "Partial: throws on empty vector. Use scanr with explicit initial value." name: Data.Vector.Unboxed.scanr1 within: [] - message: "Partial: throws on empty vector. Use scanr' with explicit initial value."- name: "Data.Vector.Unboxed.scanr1'"+ name: Data.Vector.Unboxed.scanr1' within: [] - functions: - message: "Unsafe: no bounds checking, may cause segfaults. Use (!) or (!?) instead."@@ -4006,13 +4006,13 @@ name: Data.Vector.Storable.Mutable.unsafeWith within: [] - functions:- - message: "Discards error info. Use decodeEither' or decodeThrow instead."+ - message: Discards error info. Use decodeEither' or decodeThrow instead. name: Data.Yaml.decode within: [] - message: Discards error info. Use decodeFileEither or decodeFileThrow instead. name: Data.Yaml.decodeFile within: [] - functions:- - message: "Deprecated. Use decodeEither' instead for ParseException details."+ - message: Deprecated. Use decodeEither' instead for ParseException details. name: Data.Yaml.decodeEither within: []
CHANGELOG.md view
@@ -7,6 +7,14 @@ ## [Unreleased] +## [1.1.6.4] - 2026-12-02++### Changed++- Replace the test framework `sydtest` with `sandwich`.+ Environments that build the tests, such as Stackage and nixpkgs,+ no longer need `sydtest`, which is distributed under a custom license that is not OSI-approved+ ## [1.1.6.3] - 2026-11-19 ### Fixed
README.md view
@@ -171,7 +171,7 @@ ## Nix このプロジェクトは開発環境として、-[haskell.nix](https://input-output-hk.github.io/haskell.nix/)+[haskell.nix](https://ican-group.github.io/haskell.nix/) を使用しています。 あくまで開発環境として利用しているだけなので、
himari.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.12 name: himari-version: 1.1.6.3+version: 1.1.6.4 synopsis: A standard library for Haskell as an alternative to rio description: A standard library for Haskell inspired by rio.@@ -147,13 +147,7 @@ main-is: Main.hs -- cabal-gild: discover ./test --exclude=**/Main.hs other-modules:- Himari.CharSpec- Himari.Env.SimpleSpec- Himari.Prelude.FunctorSpec Himari.Title- HlintBaseSpec- HlintExtensionSpec- HlintReexportSpec HlintRunner HlintSamples.BasePartial HlintSamples.ExtensionDangerous@@ -163,8 +157,15 @@ HlintSamples.ReexportImportForms HlintSamples.ReexportSafePrelude HlintSamples.UnliftioPreference- HlintUnliftioSpec- TitleSpec+ Spec+ Spec.Himari.CharSpec+ Spec.Himari.Env.SimpleSpec+ Spec.Himari.Prelude.FunctorSpec+ Spec.HlintBaseSpec+ Spec.HlintExtensionSpec+ Spec.HlintReexportSpec+ Spec.HlintUnliftioSpec+ Spec.TitleSpec ghc-options: -threaded@@ -172,13 +173,15 @@ -with-rtsopts=-N build-depends:- QuickCheck >=2.15.0.1,+ QuickCheck, himari,- sydtest >=0.18.0.0,- yaml >=0.11.11.2,+ sandwich,+ sandwich-quickcheck,+ yaml, build-tool-depends:- hlint:hlint >=3.10+ hlint:hlint,+ sandwich:sandwich-discover, -- hlint経由のghc-lib-parserの参照バージョンに問題が出やすいので、 -- こちら側でヒントを出して誘導します。
− test/Himari/CharSpec.hs
@@ -1,220 +0,0 @@--- このテストモジュール自体が避けるべき関数のラッパーを作れているか検査するため、--- 避けるべき関数を呼び出して振る舞いの互換性の検査などを行う必要があります。-{- HLINT ignore "Avoid restricted function" -}-module Himari.CharSpec (spec) where--import Data.Char (chr, digitToInt, intToDigit, isHexDigit, ord, toUpper)-import Himari hiding (elements)-import Test.QuickCheck-import Test.Syd--spec :: Spec-spec = do- describe "digitToIntMay" $ do- describe "boundary values" $ do- it "returns Just 0 for '0'" $ do- digitToIntMay '0' `shouldBe` Just 0-- it "returns Just 9 for '9'" $ do- digitToIntMay '9' `shouldBe` Just 9-- it "returns Just 10 for 'a'" $ do- digitToIntMay 'a' `shouldBe` Just 10-- it "returns Just 10 for 'A'" $ do- digitToIntMay 'A' `shouldBe` Just 10-- it "returns Just 15 for 'f'" $ do- digitToIntMay 'f' `shouldBe` Just 15-- it "returns Just 15 for 'F'" $ do- digitToIntMay 'F' `shouldBe` Just 15-- it "returns Nothing for 'g'" $ do- digitToIntMay 'g' `shouldBe` Nothing-- it "returns Nothing for 'G'" $ do- digitToIntMay 'G' `shouldBe` Nothing-- it "returns Nothing for ' '" $ do- digitToIntMay ' ' `shouldBe` Nothing-- describe "all valid hex digits" $ do- it "returns Just for all decimal digits" $ do- forM_ ['0' .. '9'] $ \c ->- digitToIntMay c `shouldSatisfy` isJust-- it "returns Just for all lowercase hex letters" $ do- forM_ ['a' .. 'f'] $ \c ->- digitToIntMay c `shouldSatisfy` isJust-- it "returns Just for all uppercase hex letters" $ do- forM_ ['A' .. 'F'] $ \c ->- digitToIntMay c `shouldSatisfy` isJust-- it "matches digitToInt for all valid characters" $ do- let validChars = ['0' .. '9'] <> ['a' .. 'f'] <> ['A' .. 'F']- forM_ validChars $ \c ->- digitToIntMay c `shouldBe` Just (digitToInt c)-- describe "QuickCheck properties" $ do- it "returns Just for hex digit characters" $ do- property . forAll (elements (['0' .. '9'] <> ['a' .. 'f'] <> ['A' .. 'F'])) $ \c ->- isJust (digitToIntMay c)-- it "returns Nothing for non-hex characters" $ do- property . forAll (elements (['g' .. 'z'] <> ['G' .. 'Z'] <> [' ', '!', '@', '#'])) $ \c ->- isNothing (digitToIntMay c)-- it "matches digitToInt for all valid hex digit inputs" $ do- property . forAll (elements (['0' .. '9'] <> ['a' .. 'f'] <> ['A' .. 'F'])) $ \c ->- digitToIntMay c == Just (digitToInt c)-- it "agrees with isHexDigit on validity" $ do- property $ \c ->- isJust (digitToIntMay c) == isHexDigit c-- it "returns values in range 0-15 for valid inputs" $ do- property . forAll (elements (['0' .. '9'] <> ['a' .. 'f'] <> ['A' .. 'F'])) $ \c ->- case digitToIntMay c of- Just n -> n >= 0 && n <= 15- Nothing -> False-- it "lowercase and uppercase give same result" $ do- property . forAll (elements ['a' .. 'f']) $ \c ->- digitToIntMay c == digitToIntMay (toUpper c)-- describe "intToDigitMay" $ do- describe "boundary values" $ do- it "returns Just '0' for 0" $ do- intToDigitMay 0 `shouldBe` Just '0'-- it "returns Just 'f' for 15" $ do- intToDigitMay 15 `shouldBe` Just 'f'-- it "returns Nothing for -1" $ do- intToDigitMay (-1) `shouldBe` Nothing-- it "returns Nothing for 16" $ do- intToDigitMay 16 `shouldBe` Nothing-- describe "all valid values (0-15)" $ do- it "returns Just for all values in range" $ do- let validRange = [0 .. 15]- forM_ validRange $ \n ->- intToDigitMay n `shouldSatisfy` isJust-- it "matches intToDigit for all valid values" $ do- let validRange = [0 .. 15]- forM_ validRange $ \n ->- intToDigitMay n `shouldBe` Just (intToDigit n)-- describe "QuickCheck properties" $ do- it "returns Just for values in range 0-15" $ do- property . forAll (choose (0, 15)) $ \n ->- isJust (intToDigitMay n)-- it "returns Nothing for negative values" $ do- property . forAll (choose (-1000, -1)) $ \n ->- isNothing (intToDigitMay n)-- it "returns Nothing for values greater than 15" $ do- property . forAll (choose (16, 1000)) $ \n ->- isNothing (intToDigitMay n)-- it "matches intToDigit for all valid inputs" $ do- property . forAll (choose (0, 15)) $ \n ->- intToDigitMay n == Just (intToDigit n)-- it "produces lowercase hex digits for 10-15" $ do- property . forAll (choose (10, 15)) $ \n ->- case intToDigitMay n of- Just c -> c `elem` ['a' .. 'f']- Nothing -> False-- it "produces decimal digits for 0-9" $ do- property . forAll (choose (0, 9)) $ \n ->- case intToDigitMay n of- Just c -> c `elem` ['0' .. '9']- Nothing -> False-- describe "chrMay" $ do- describe "boundary values" $ do- it "returns Just for 0 (NUL)" $ do- chrMay 0 `shouldBe` Just '\0'-- it "returns Just 'A' for 65" $ do- chrMay 65 `shouldBe` Just 'A'-- it "returns Just for max valid code point (0x10FFFF)" $ do- chrMay 0x10FFFF `shouldBe` Just '\x10FFFF'-- it "returns Nothing for -1" $ do- chrMay (-1) `shouldBe` Nothing-- it "returns Nothing for 0x110000 (beyond max)" $ do- chrMay 0x110000 `shouldBe` Nothing-- it "returns Nothing for surrogate start (0xD800)" $ do- chrMay 0xD800 `shouldBe` Nothing-- it "returns Nothing for surrogate end (0xDFFF)" $ do- chrMay 0xDFFF `shouldBe` Nothing-- it "returns Nothing for surrogate middle (0xDC00)" $ do- chrMay 0xDC00 `shouldBe` Nothing-- describe "valid ranges" $ do- it "returns Just for code points before surrogate range" $ do- chrMay 0xD7FF `shouldSatisfy` isJust-- it "returns Just for code points after surrogate range" $ do- chrMay 0xE000 `shouldSatisfy` isJust-- it "returns Just for common characters" $ do- forM_ [('a', 97), ('z', 122), ('0', 48), ('9', 57)] $ \(expected, n) ->- chrMay n `shouldBe` Just expected-- describe "QuickCheck properties" $ do- it "returns Just for valid BMP code points (excluding surrogates)" $ do- property . forAll (choose (0, 0xD7FF)) $ \n ->- isJust (chrMay n)-- it "returns Just for valid code points after surrogates" $ do- property . forAll (choose (0xE000, 0x10FFFF)) $ \n ->- isJust (chrMay n)-- it "returns Nothing for surrogate range" $ do- property . forAll (choose (0xD800, 0xDFFF)) $ \n ->- isNothing (chrMay n)-- it "returns Nothing for negative values" $ do- property . forAll (choose (-1000, -1)) $ \n ->- isNothing (chrMay n)-- it "returns Nothing for values beyond max code point" $ do- property . forAll (choose (0x110000, 0x200000)) $ \n ->- isNothing (chrMay n)-- it "matches chr for all valid inputs" $ do- property . forAll (choose (0, 0xD7FF)) $ \n ->- chrMay n == Just (chr n)-- it "is inverse of ord for valid characters" $ do- property $ \c ->- chrMay (ord c) == Just c-- it "never throws an exception for any Int value" $ do- withNumTests 10000 . property $ \n ->- case chrMay n of- Just _ -> True- Nothing -> True--#if !MIN_VERSION_QuickCheck(2,18,0)--- | `withNumTests`は`QuickCheck 2.18.0.0`で、--- `withMaxSuccess`から改名された関数です。--- それより古いQuickCheckには存在しないため、--- `withMaxSuccess`で互換定義します。-withNumTests :: (Testable prop) => Int -> prop -> Property-withNumTests = withMaxSuccess-#endif
− test/Himari/Env/SimpleSpec.hs
@@ -1,110 +0,0 @@-{-# LANGUAGE TemplateHaskell #-}--module Himari.Env.SimpleSpec (spec) where--import Himari-import Test.Syd--spec :: Spec-spec = do- -- テスト実行時に実際のターミナルへログを出力すると、- -- Errorなどがログディスプレイでハイライトされて紛らわしいので、- -- ログの出力を検証しないテストでは`runSimpleNoLogEnv`で出力を破棄する。- describe "logging" $ do- it- "outputs debug level logs"- (runSimpleNoLogEnv $ $(logDebug) "debug message" :: IO ())-- it- "outputs info level logs"- (runSimpleNoLogEnv $ $(logInfo) "info message" :: IO ())-- it- "outputs warning level logs"- (runSimpleNoLogEnv $ $(logWarn) "warning message" :: IO ())-- it- "outputs error level logs"- (runSimpleNoLogEnv $ $(logError) "error message" :: IO ())-- it- "handles multiple log calls"- ( runSimpleNoLogEnv- ( do- $(logInfo) "first log"- $(logInfo) "second log"- $(logDebug) "third log"- )- :: IO ()- )-- it "works with monadic composition" $ do- result <- runSimpleNoLogEnv $ do- $(logInfo) "starting computation"- let x = 20 :: Int- $(logDebug) ("intermediate value: " <> convert (show x))- let y = x + 22- $(logInfo) "computation complete"- pure y- result `shouldBe` 42-- it- "supports monad-logger functions"- ( runSimpleNoLogEnv- ( do- logInfoN "using logInfoN"- logDebugN "using logDebugN"- logWarnN "using logWarnN"- )- :: IO ()- )-- describe "custom log output" $ do- it "can capture log messages" $ do- chan <- newTChanIO :: IO (TChan Text)- let customLogOutput _loc _src _level msg = do- let msgText = convert (fromLogStr msg)- atomically $ writeTChan chan msgText- runSimpleEnvWith customLogOutput $ do- $(logInfo) "custom output test"- message <- atomically $ readTChan chan- message `shouldBe` "custom output test"-- it "captures log level information" $ do- chan <- newTChanIO :: IO (TChan (Text, LogLevel))- let customLogOutput _loc _src level msg = do- let msgText = convert (fromLogStr msg)- atomically $ writeTChan chan (msgText, level)- runSimpleEnvWith customLogOutput $ do- $(logError) "error log"- $(logWarn) "warning log"- msg1 <- atomically $ readTChan chan- msg2 <- atomically $ readTChan chan- [msg1, msg2] `shouldBe` [("error log", LevelError), ("warning log", LevelWarn)]-- describe "basic execution" $ do- it "executes actions successfully" $ do- result <- runSimpleEnv $ pure (42 :: Int)- result `shouldBe` 42-- it "can access and use the environment" $ do- result <- runSimpleNoLogEnv $ do- $(logInfo) "computing result"- pure (10 + 32 :: Int)- result `shouldBe` 42-- describe "Magnify instance" $ do- it "works with magnify to access a sub-environment" $ do- let- -- 小さな環境 (Text) を要求するアクション- subAction :: Himari Text Text- subAction = do- env <- ask- pure $ env <> " world"- -- 大きな環境 (Int, Text)- bigEnv :: (Int, Text)- bigEnv = (100, "hello")- -- (Int, Text) の環境下で、_2 レンズを使って Text にズームして実行- -- これがコンパイル・実行できれば Effect IO へのマッピングは成功している- result <- runHimari bigEnv $ magnify _2 subAction- result `shouldBe` "hello world"
− test/Himari/Prelude/FunctorSpec.hs
@@ -1,41 +0,0 @@--- | Tests for functor-related re-exports in Himari.Prelude.-module Himari.Prelude.FunctorSpec (spec) where--import Data.Text qualified as T-import Himari-import Test.Syd--spec :: Spec-spec = do- describe "Data.Bifunctor" $ do- it "bimap is available and works correctly" $ do- bimap (+ 1) (* 2) (Left 5 :: Either Int Int) `shouldBe` Left 6- bimap (+ 1) (* 2) (Right 3 :: Either Int Int) `shouldBe` Right 6-- it "bifunctorインスタンスが使える" $ do- bimap (convert . show) T.length (42 :: Int, "hello") `shouldBe` ("42" :: Text, 5 :: Int)-- describe "Data.Functor.Const" $ do- it "Const functor is available" $ do- let x = Const 42 :: Const Int Text- getConst x `shouldBe` (42 :: Int)-- it "Const functor maps correctly (ignores function)" $ do- let x = Const 42 :: Const Int Text- let y = fmap (const ("ignored" :: Text)) x- getConst y `shouldBe` (42 :: Int)-- describe "Data.Functor.Identity" $ do- it "Identity functor is available" $ do- let x = Identity (42 :: Int)- runIdentity x `shouldBe` (42 :: Int)-- it "Identity functor maps correctly" $ do- let x = Identity (5 :: Int)- let y = fmap (* 2) x- runIdentity y `shouldBe` (10 :: Int)-- it "Identity applicative works" $ do- let f = Identity ((+ 1) :: Int -> Int)- let x = Identity (10 :: Int)- runIdentity (f <*> x) `shouldBe` (11 :: Int)
− test/HlintBaseSpec.hs
@@ -1,49 +0,0 @@-module HlintBaseSpec (spec) where--import Himari-import HlintRunner-import Test.Syd--spec :: Spec-spec = do- describe "hlint base library rules" . withSample "BasePartial.hs" $ do- describe "Data.List partial functions" $ do- itWithOuter "head through Himari should warn (partial function)" $ \sample ->- shouldWarnFunction sample "useHead" "head" "headMay"-- itWithOuter "Data.List.head should warn (partial function)" $ \sample ->- shouldWarnFunction sample "useHeadQualified" "L.head" "headMay"-- describe "NonEmpty.head should be safe" $ do- itWithOuter "Data.List.NonEmpty.head should NOT warn (it's safe)" $ \sample ->- sample `shouldNotWarnFunctionIn` "useNonEmptyHead"-- describe "Debug.Trace functions suggest pTrace*" $ do- itWithOuter "Debug.Trace.trace should suggest pTrace" $ \sample ->- shouldSuggestIn sample "useTrace" "Use pTrace"-- itWithOuter "Debug.Trace.traceShow should suggest pTraceShow" $ \sample ->- shouldSuggestIn sample "useTraceShow" "Use pTraceShow"-- itWithOuter "Debug.Trace.traceM should suggest pTraceM" $ \sample ->- shouldSuggestIn sample "useTraceM" "Use pTraceM"-- describe "Numeric integer-showing functions are partial" $ do- itWithOuter "showHex should warn (partial function)" $ \sample ->- shouldWarnFunction sample "useShowHex" "showHex" "non-negative"-- itWithOuter "showInt should warn (partial function)" $ \sample ->- shouldWarnFunction sample "useShowInt" "showInt" "non-negative"-- itWithOuter "showOct should warn (partial function)" $ \sample ->- shouldWarnFunction sample "useShowOct" "showOct" "non-negative"-- itWithOuter "showBin should warn (partial function)" $ \sample ->- shouldWarnFunction sample "useShowBin" "showBin" "non-negative"-- itWithOuter "showIntAtBase should warn (partial function)" $ \sample ->- shouldWarnFunction sample "useShowIntAtBase" "showIntAtBase" "base > 1"-- describe "Data.Char partial functions" $ do- itWithOuter "intToDigit should warn (partial function)" $ \sample ->- shouldWarnFunction sample "useShowIntAtBase" "intToDigit" "intToDigitMay"
− test/HlintExtensionSpec.hs
@@ -1,19 +0,0 @@-module HlintExtensionSpec (spec) where--import Himari-import HlintRunner-import Test.Syd--spec :: Spec-spec = do- describe "hlint extension restriction rules" . withSample "ExtensionDangerous.hs" $ do- describe "Dangerous extensions" $ do- itWithOuter "AllowAmbiguousTypes should warn" $ \sample ->- sample `shouldWarnExtension` "AllowAmbiguousTypes"-- describe "Discouraged extensions" $ do- itWithOuter "ImplicitParams should warn" $ \sample ->- sample `shouldWarnExtension` "ImplicitParams"-- itWithOuter "UndecidableInstances should warn" $ \sample ->- sample `shouldWarnExtension` "UndecidableInstances"
− test/HlintReexportSpec.hs
@@ -1,241 +0,0 @@-module HlintReexportSpec (spec) where--import Data.Set qualified as Set-import Data.Text qualified as T-import Himari-import HlintRunner-import Test.Syd--spec :: Spec-spec = do- describe "hlint rules for symbols re-exported through himari" $ do- describe "rules in .hlint.yaml" . beforeAll loadRestrictedFunctionNames $ do- itWithOuter "rules for Himari should be exactly the tested functions" $ \names ->- rulesThrough "Himari" names `shouldBe` reexportedFunctionNames-- itWithOuter "rules for Himari.Prelude should be exactly the tested functions" $ \names ->- rulesThrough "Himari.Prelude" names `shouldBe` reexportedFunctionNames-- itWithOuter "rules for Himari.SafePrelude should leave out the functions it lacks" $ \names ->- rulesThrough "Himari.SafePrelude" names- `shouldBe` (reexportedFunctionNames `Set.difference` preludeOnlyFunctionNames)-- describe "import Himari" . withSample "ReexportHimari.hs" $ do- describe "every restricted function re-exported by Himari should warn" $ do- forM_ reexportedRestrictedFunctions $ \(declName, function, fragment) ->- itWithOuter (convert function <> " should warn with its own message") $ \sample ->- shouldWarnFunction sample declName function fragment-- describe "functions restricted by a rule without a module name should warn" $ do- itWithOuter "throwString should warn" $ \sample ->- shouldWarnFunction sample "useThrowString" "throwString" "typed exceptions with throwM"-- describe "functions of both Data.List and Data.Foldable should have a single message" $ do- itWithOuter "every function should be among the tested functions" $ \(_ :: Sample) ->- fmap snd listAndFoldableFunctions `shouldBe` listAndFoldableFunctionNames-- forM_ listAndFoldableFunctions $ \(declName, function) ->- itWithOuter (convert function <> " should not have concatenated messages") $ \sample ->- shouldWarnFunctionOnce sample declName function "Partial:"-- describe "total alternatives should NOT warn" $ do- itWithOuter "headMay should NOT warn" $ \sample ->- sample `shouldNotWarnFunctionIn` "useHeadMay"-- itWithOuter "fromMaybe should NOT warn" $ \sample ->- sample `shouldNotWarnFunctionIn` "useFromMaybe"-- describe "UnliftIO versions exported by Himari should NOT warn" $ do- forM_ unliftioDeclarations $ \declName ->- itWithOuter (convert declName <> " should NOT warn") $ \sample ->- sample `shouldNotWarnFunctionIn` declName-- describe "import Himari.Prelude" . withSample "ReexportHimariPrelude.hs" $ do- itWithOuter "head should warn" $ \sample ->- shouldWarnFunction sample "useHead" "head" "headMay"-- itWithOuter "foldl1 should warn with a single message" $ \sample ->- shouldWarnFunctionOnce sample "useFoldl1" "foldl1" "Partial:"-- itWithOuter "bifoldl1 should warn" $ \sample ->- shouldWarnFunction sample "useBifoldl1" "bifoldl1" "bifoldl with a default value"-- itWithOuter "fromJust should warn" $ \sample ->- shouldWarnFunction sample "useFromJust" "fromJust" "fromMaybe"-- itWithOuter "readFile should warn" $ \sample ->- shouldWarnFunction sample "useReadFile" "readFile" "Lazy IO"-- itWithOuter "singular should warn" $ \sample ->- shouldWarnFunction sample "useSingular" "singular" "(^?)"-- itWithOuter "stringException should warn" $ \sample ->- shouldWarnFunction- sample- "useStringException"- "stringException"- "Define a proper exception type"-- itWithOuter "headMay should NOT warn" $ \sample ->- sample `shouldNotWarnFunctionIn` "useHeadMay"-- itWithOuter "catch of UnliftIO should NOT warn" $ \sample ->- sample `shouldNotWarnFunctionIn` "useCatch"-- describe "import Himari.SafePrelude" . withSample "ReexportSafePrelude.hs" $ do- itWithOuter "head should warn" $ \sample ->- shouldWarnFunction sample "useHead" "head" "headMay"-- itWithOuter "foldl1 should warn with a single message" $ \sample ->- shouldWarnFunctionOnce sample "useFoldl1" "foldl1" "Partial:"-- itWithOuter "bifoldl1 should warn" $ \sample ->- shouldWarnFunction sample "useBifoldl1" "bifoldl1" "bifoldl with a default value"-- itWithOuter "fromJust should warn" $ \sample ->- shouldWarnFunction sample "useFromJust" "fromJust" "fromMaybe"-- itWithOuter "readFile should warn" $ \sample ->- shouldWarnFunction sample "useReadFile" "readFile" "Lazy IO"-- itWithOuter "singular should warn" $ \sample ->- shouldWarnFunction sample "useSingular" "singular" "(^?)"-- itWithOuter "headMay should NOT warn" $ \sample ->- sample `shouldNotWarnFunctionIn` "useHeadMay"-- describe "import forms of Himari" . withSample "ReexportImportForms.hs" $ do- itWithOuter "head qualified with the alias of Himari should warn" $ \sample ->- shouldWarnFunction sample "useQualifiedHead" "H.head" "headMay"-- itWithOuter "readFile qualified with the alias of Himari should warn" $ \sample ->- shouldWarnFunction sample "useQualifiedReadFile" "H.readFile" "Lazy IO"-- itWithOuter "tail should warn even though other names are hidden" $ \sample ->- shouldWarnFunction sample "useTail" "tail" "tailMay"-- itWithOuter "head of Data.List.NonEmpty should NOT warn when hidden from Himari" $ \sample ->- sample `shouldNotWarnFunctionIn` "useNonEmptyHead"-- itWithOuter "head qualified with Data.List.NonEmpty should NOT warn" $ \sample ->- sample `shouldNotWarnFunctionIn` "useNonEmptyHeadQualified"-- itWithOuter "definition of a user function named last should NOT warn" $ \sample ->- sample `shouldNotWarnFunctionIn` "last"-- itWithOuter "use of a user function named last should NOT warn" $ \sample ->- sample `shouldNotWarnFunctionIn` "useOwnLast"-- describe "explicit import list of Himari" . withSample "ReexportExplicitImport.hs" $ do- itWithOuter "head should warn" $ \sample ->- shouldWarnFunction sample "useHead" "head" "headMay"-- itWithOuter "readFile should warn" $ \sample ->- shouldWarnFunction sample "useReadFile" "readFile" "Lazy IO"-- itWithOuter "headMay should NOT warn" $ \sample ->- sample `shouldNotWarnFunctionIn` "useHeadMay"---- | Module qualified names of the rules for the functions re-exported through the module.--- Rules for the modules below it, such as @Himari.Prelude.head@ for @Himari@, are left out.--- This does not support operators that contain a dot.-rulesThrough :: Text -> [Text] -> Set.Set Text-rulesThrough reexporter ruleNames =- Set.fromList- [ function- | ruleName <- ruleNames- , Just function <- [T.stripPrefix (reexporter <> ".") ruleName]- , not ("." `T.isInfixOf` function)- ]---- | Names of the functions in 'reexportedRestrictedFunctions'.-reexportedFunctionNames :: Set.Set Text-reexportedFunctionNames =- Set.fromList [function | (_, function, _) <- reexportedRestrictedFunctions]---- | Functions re-exported by "Himari.Prelude" but not by "Himari.SafePrelude".-preludeOnlyFunctionNames :: Set.Set Text-preludeOnlyFunctionNames = Set.fromList ["stringException"]---- | Declarations of the sample paired with the restricted function they use--- and a fragment of the message of its rule.--- These are all the functions that have a rule qualified with a module of himari in @.hlint.yaml@,--- which is verified against @.hlint.yaml@ by the tests.--- They are re-exported by "Himari" as the very same entity as the original one.-reexportedRestrictedFunctions :: [(Text, Text, Text)]-reexportedRestrictedFunctions =- [ ("useHead", "head", "headMay")- , ("useTail", "tail", "tailMay")- , ("useInit", "init", "initMay")- , ("useLast", "last", "lastMay")- , ("useCycle", "cycle", "cycleMay")- , ("useScanl1", "scanl1", "scanl1May")- , ("useScanr1", "scanr1", "scanr1May")- , ("useFoldl1", "foldl1", "foldl1May from Safe.Foldable")- , ("useFoldr1", "foldr1", "foldr1May from Safe.Foldable")- , ("useMaximum", "maximum", "maximumMay or maximumBound from Safe.Foldable")- , ("useMinimum", "minimum", "minimumMay or minimumBound from Safe.Foldable")- , ("useMaximumBy", "maximumBy", "maximumByMay or maximumBoundBy from Safe.Foldable")- , ("useMinimumBy", "minimumBy", "minimumByMay or minimumBoundBy from Safe.Foldable")- , ("useBifoldl1", "bifoldl1", "bifoldl with a default value")- , ("useBifoldr1", "bifoldr1", "bifoldr with a default value")- , ("useBimaximum", "bimaximum", "bifoldr with explicit initial value")- , ("useBiminimum", "biminimum", "bifoldr with explicit initial value")- , ("useBimaximumBy", "bimaximumBy", "bifoldr with explicit initial value")- , ("useBiminimumBy", "biminimumBy", "bifoldr with explicit initial value")- , ("useFromJust", "fromJust", "fromMaybe")- , ("useGetChar", "getChar", "Encoding depends on LANG")- , ("useGetLine", "getLine", "Encoding depends on LANG")- , ("useGetContents", "getContents", "Use strict Text or ByteString")- , ("useInteract", "interact", "Lazy IO + env-dependent encoding.")- , ("useReadIO", "readIO", "partial (uses read)")- , ("useReadLn", "readLn", "partial (uses read)")- , ("usePutChar", "putChar", "Encoding depends on LANG")- , ("usePutStr", "putStr", "Encoding depends on LANG")- , ("usePutStrLn", "putStrLn", "Encoding depends on LANG")- , ("usePrint", "print", "Encoding depends on LANG")- , ("useReadFile", "readFile", "Data.Text.IO.readFile")- , ("useWriteFile", "writeFile", "Data.Text.IO.writeFile")- , ("useAppendFile", "appendFile", "Data.Text.IO.appendFile")- , ("useSingular", "singular", "(^?)")- , ("useUnsafeSingular", "unsafeSingular", "0 or >1 elements")- , ("useUnsafePartsOf", "unsafePartsOf", "list length changes")- , ("useIunsafePartsOf", "iunsafePartsOf", "list length changes")- , ("useStringException", "stringException", "Define a proper exception type")- ]---- | Functions that both "Data.List" and "Data.Foldable" export as the very same entity.--- Both modules have a rule for them, so their messages are prone to be concatenated.--- The declarations that use them are looked up in 'reexportedRestrictedFunctions'.-listAndFoldableFunctions :: [(Text, Text)]-listAndFoldableFunctions =- [ (declName, function)- | (declName, function, _) <- reexportedRestrictedFunctions- , function `elem` listAndFoldableFunctionNames- ]---- | Names of the functions in 'listAndFoldableFunctions'.-listAndFoldableFunctionNames :: [Text]-listAndFoldableFunctionNames =- [ "foldl1"- , "foldr1"- , "maximum"- , "minimum"- , "maximumBy"- , "minimumBy"- ]---- | Declarations of the sample that use the UnliftIO version of a name--- whose non-UnliftIO version has a rule in @.hlint.yaml@.-unliftioDeclarations :: [Text]-unliftioDeclarations =- [ "useCatch"- , "useBracket"- , "useFinally"- , "useTry"- , "useWithMVar"- , "useModifyMVar"- , "useTimeout"- , "useMyThreadId"- , "useDoesFileExist"- ]
test/HlintRunner.hs view
@@ -3,6 +3,7 @@ -- so a warning for one declaration can never satisfy an expectation for another one. module HlintRunner ( Sample+ , HasSample , withSample , loadRestrictedFunctionNames , shouldWarnFunction@@ -16,7 +17,7 @@ import Data.Text.IO qualified as T import Data.Yaml qualified as Yaml import Himari-import Test.Syd+import Test.Sandwich -- | A single hint reported by @hlint --json@. data Idea = Idea@@ -49,9 +50,9 @@ -- A sample hlint failed to parse is rejected here, -- because hlint reports nothing but the parse error for it -- and every negative expectation on it would pass without checking anything.-loadSample :: FilePath -> IO Sample+loadSample :: (MonadIO m) => FilePath -> m Sample loadSample path = do- source <- T.readFile path+ source <- liftIO $ T.readFile path (_, stdoutOutput, stderrOutput) <- readProcess $ proc "hlint" ["--json", path] case eitherDecode stdoutOutput of Right ideas -> case filter (\idea -> idea.severity == "Error") ideas of@@ -68,9 +69,23 @@ <> "\n" <> T.unpack (convert stderrOutput) +-- | Label of the sample shared by 'withSample'.+sampleLabel :: Label "sample" Sample+sampleLabel = Label++-- | A test context that has the sample shared by 'withSample'.+type HasSample context = HasLabel context "sample" Sample+ -- | Run hlint once on a file of @test/HlintSamples@ and share the result among the tests.-withSample :: FilePath -> TestDefM '[Sample] () () -> Spec-withSample name = beforeAll (loadSample ("test/HlintSamples/" <> name))+-- The expectations of this module read the sample from the test context.+withSample+ :: FilePath -> SpecFree (LabelValue "sample" Sample :> context) IO () -> SpecFree context IO ()+withSample name =+ introduce+ ("hlint " <> name)+ sampleLabel+ (loadSample ("test/HlintSamples/" <> name))+ (const (pure ())) -- | A rule of @.hlint.yaml@. -- Only the function restrictions are read, the other kinds of rules have no @functions@ key.@@ -90,9 +105,9 @@ instance FromJSON FunctionRestriction -- | Names of all the functions restricted by the project's @.hlint.yaml@.-loadRestrictedFunctionNames :: IO [Text]+loadRestrictedFunctionNames :: (MonadIO m) => m [Text] loadRestrictedFunctionNames =- Yaml.decodeFileEither ".hlint.yaml" >>= \case+ liftIO (Yaml.decodeFileEither ".hlint.yaml") >>= \case Right (rules :: [Rule]) -> pure [restriction.name | rule <- rules, restriction <- fold rule.functions] Left err ->@@ -102,7 +117,7 @@ -- | Fail unless the sample defines the declaration. -- This keeps negative expectations from passing vacuously -- when a declaration is renamed or removed from the sample.-shouldDefine :: (HasCallStack) => Sample -> Text -> IO ()+shouldDefine :: (HasCallStack, MonadIO m) => Sample -> Text -> m () shouldDefine sample declName = unless (any (T.isPrefixOf (declName <> " ::")) (T.lines sample.source)) . expectationFailure $ sample.path <> " does not define " <> T.unpack declName@@ -116,8 +131,10 @@ filter (\idea -> idea.hint == restrictedFunctionHint && declName `elem` idea.decl) sample.ideas -- | Expect exactly one restricted function warning for the function inside the declaration.-expectSingleWarning :: (HasCallStack) => Sample -> Text -> Text -> IO Idea-expectSingleWarning sample declName function = do+expectSingleWarning+ :: (HasCallStack, HasSample context) => Text -> Text -> ExampleT context IO Idea+expectSingleWarning declName function = do+ sample <- getContext sampleLabel sample `shouldDefine` declName case filter (\idea -> idea.from == function) (restrictedFunctionsIn declName sample) of [idea] -> pure idea@@ -132,34 +149,39 @@ -- | Expect the function used inside the declaration to be warned -- with a message that contains the fragment.-shouldWarnFunction :: (HasCallStack) => Sample -> Text -> Text -> Text -> IO ()-shouldWarnFunction sample declName function fragment = do- idea <- expectSingleWarning sample declName function- idea.note `shouldSatisfy` any (T.isInfixOf fragment)+shouldWarnFunction+ :: (HasCallStack, HasSample context) => Text -> Text -> Text -> ExampleT context IO ()+shouldWarnFunction declName function fragment = do+ idea <- expectSingleWarning declName function+ idea.note `shouldContainPredicate` T.isInfixOf fragment -- | Expect the function used inside the declaration to be warned with a single message. -- hlint concatenates the messages of all matching rules without any separator, -- so the message of a function matched by several rules contains the marker more than once.-shouldWarnFunctionOnce :: (HasCallStack) => Sample -> Text -> Text -> Text -> IO ()-shouldWarnFunctionOnce sample declName function marker = do- idea <- expectSingleWarning sample declName function+shouldWarnFunctionOnce+ :: (HasCallStack, HasSample context) => Text -> Text -> Text -> ExampleT context IO ()+shouldWarnFunctionOnce declName function marker = do+ idea <- expectSingleWarning declName function fmap (T.count marker) idea.note `shouldBe` [1] -- | Expect no restricted function warning inside the declaration.-shouldNotWarnFunctionIn :: (HasCallStack) => Sample -> Text -> IO ()-shouldNotWarnFunctionIn sample declName = do+shouldNotWarnFunctionIn :: (HasCallStack, HasSample context) => Text -> ExampleT context IO ()+shouldNotWarnFunctionIn declName = do+ sample <- getContext sampleLabel sample `shouldDefine` declName restrictedFunctionsIn declName sample `shouldBe` [] -- | Expect a hint with the given title inside the declaration.-shouldSuggestIn :: (HasCallStack) => Sample -> Text -> Text -> IO ()-shouldSuggestIn sample declName hintTitle = do+shouldSuggestIn :: (HasCallStack, HasSample context) => Text -> Text -> ExampleT context IO ()+shouldSuggestIn declName hintTitle = do+ sample <- getContext sampleLabel sample `shouldDefine` declName filter (\idea -> declName `elem` idea.decl) sample.ideas- `shouldSatisfy` any (\idea -> idea.hint == hintTitle)+ `shouldContainPredicate` (\idea -> idea.hint == hintTitle) -- | Expect the language extension to be reported as restricted.-shouldWarnExtension :: (HasCallStack) => Sample -> Text -> IO ()-shouldWarnExtension sample extension =+shouldWarnExtension :: (HasCallStack, HasSample context) => Text -> ExampleT context IO ()+shouldWarnExtension extension = do+ sample <- getContext sampleLabel filter (\idea -> idea.hint == "Avoid restricted extensions") sample.ideas- `shouldSatisfy` any (\idea -> ("LANGUAGE " <> extension <> " ") `T.isInfixOf` idea.from)+ `shouldContainPredicate` (\idea -> ("LANGUAGE " <> extension <> " ") `T.isInfixOf` idea.from)
− test/HlintUnliftioSpec.hs
@@ -1,33 +0,0 @@-module HlintUnliftioSpec (spec) where--import Himari-import HlintRunner-import Test.Syd--spec :: Spec-spec = do- describe "hlint unliftio preference rules" . withSample "UnliftioPreference.hs" $ do- describe "Control" $ do- describe "Exception" $ do- itWithOuter "catch should warn to use UnliftIO.Exception" $ \sample ->- shouldWarnFunction sample "badCatch" "Exception.catch" "UnliftIO.Exception.catch"-- itWithOuter "bracket should warn to use UnliftIO.Exception" $ \sample ->- shouldWarnFunction sample "badBracket" "Exception.bracket" "UnliftIO.Exception.bracket"-- itWithOuter "finally should warn to use UnliftIO.Exception" $ \sample ->- shouldWarnFunction sample "badFinally" "Exception.finally" "UnliftIO.Exception.finally"-- itWithOuter "try should warn to use UnliftIO.Exception" $ \sample ->- shouldWarnFunction sample "badTry" "Exception.try" "UnliftIO.Exception.try"-- describe "Concurrent.MVar" $ do- itWithOuter "withMVar should warn to use UnliftIO.MVar" $ \sample ->- shouldWarnFunction sample "badWithMVar" "MVar.withMVar" "UnliftIO.MVar.withMVar"-- itWithOuter "modifyMVar_ should warn to use UnliftIO.MVar" $ \sample ->- shouldWarnFunction sample "badModifyMVar" "MVar.modifyMVar_" "UnliftIO.MVar.modifyMVar_"-- describe "System.Timeout" $ do- itWithOuter "timeout should warn to use UnliftIO.Timeout" $ \sample ->- shouldWarnFunction sample "badTimeout" "Timeout.timeout" "UnliftIO.Timeout.timeout"
test/Main.hs view
@@ -1,23 +1,8 @@ module Main (main) where import Himari-import Himari.CharSpec qualified as CharSpec-import Himari.Env.SimpleSpec qualified as SimpleSpec-import Himari.Prelude.FunctorSpec qualified as FunctorSpec-import HlintBaseSpec qualified-import HlintExtensionSpec qualified-import HlintReexportSpec qualified-import HlintUnliftioSpec qualified-import Test.Syd-import TitleSpec qualified+import Spec qualified+import Test.Sandwich main :: IO ()-main = sydTest $ do- describe "Char" CharSpec.spec- describe "Simple" SimpleSpec.spec- describe "Title" TitleSpec.spec- describe "Prelude.Functor" FunctorSpec.spec- describe "HlintUnliftio" HlintUnliftioSpec.spec- describe "HlintBase" HlintBaseSpec.spec- describe "HlintExtension" HlintExtensionSpec.spec- describe "HlintReexport" HlintReexportSpec.spec+main = runSandwichWithCommandLineArgs defaultOptions Spec.tests
+ test/Spec.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_GHC -F -pgmF sandwich-discover #-}+{-# OPTIONS_GHC -Wno-type-defaults #-}++-- | `test/Spec`以下のモジュールを、+-- sandwich-discoverで自動的に集めてテストツリーにします。+-- `test/Spec`以下の全てのモジュールは、+-- `tests`という名前でテストをexportする必要があります。+-- テストではない補助のモジュールは`test/Spec`の外に置いてください。+module Spec (tests) where++import Test.Sandwich++#insert_test_imports++tests :: TopSpec+tests = $(getSpecFromFolder defaultGetSpecFromFolderOptions)
+ test/Spec/Himari/CharSpec.hs view
@@ -0,0 +1,208 @@+-- このテストモジュール自体が避けるべき関数のラッパーを作れているか検査するため、+-- 避けるべき関数を呼び出して振る舞いの互換性の検査などを行う必要があります。+{- HLINT ignore "Avoid restricted function" -}+module Spec.Himari.CharSpec (tests) where++import Data.Char (chr, digitToInt, intToDigit, isHexDigit, ord, toUpper)+import Himari hiding (elements)+import Test.QuickCheck+import Test.Sandwich+import Test.Sandwich.QuickCheck++tests :: TopSpec+tests = describe "Char" . introduceQuickCheck $ do+ describe "digitToIntMay" $ do+ describe "boundary values" $ do+ it "returns Just 0 for '0'" $ do+ digitToIntMay '0' `shouldBe` Just 0++ it "returns Just 9 for '9'" $ do+ digitToIntMay '9' `shouldBe` Just 9++ it "returns Just 10 for 'a'" $ do+ digitToIntMay 'a' `shouldBe` Just 10++ it "returns Just 10 for 'A'" $ do+ digitToIntMay 'A' `shouldBe` Just 10++ it "returns Just 15 for 'f'" $ do+ digitToIntMay 'f' `shouldBe` Just 15++ it "returns Just 15 for 'F'" $ do+ digitToIntMay 'F' `shouldBe` Just 15++ it "returns Nothing for 'g'" $ do+ digitToIntMay 'g' `shouldBe` Nothing++ it "returns Nothing for 'G'" $ do+ digitToIntMay 'G' `shouldBe` Nothing++ it "returns Nothing for ' '" $ do+ digitToIntMay ' ' `shouldBe` Nothing++ describe "all valid hex digits" $ do+ it "returns Just for all decimal digits" $ do+ forM_ ['0' .. '9'] $ \c ->+ shouldBeJust (digitToIntMay c)++ it "returns Just for all lowercase hex letters" $ do+ forM_ ['a' .. 'f'] $ \c ->+ shouldBeJust (digitToIntMay c)++ it "returns Just for all uppercase hex letters" $ do+ forM_ ['A' .. 'F'] $ \c ->+ shouldBeJust (digitToIntMay c)++ it "matches digitToInt for all valid characters" $ do+ let validChars = ['0' .. '9'] <> ['a' .. 'f'] <> ['A' .. 'F']+ forM_ validChars $ \c ->+ digitToIntMay c `shouldBe` Just (digitToInt c)++ describe "QuickCheck properties" $ do+ prop "returns Just for hex digit characters"+ . forAll (elements (['0' .. '9'] <> ['a' .. 'f'] <> ['A' .. 'F']))+ $ \c -> isJust (digitToIntMay c)++ prop "returns Nothing for non-hex characters"+ . forAll (elements (['g' .. 'z'] <> ['G' .. 'Z'] <> [' ', '!', '@', '#']))+ $ \c -> isNothing (digitToIntMay c)++ prop "matches digitToInt for all valid hex digit inputs"+ . forAll (elements (['0' .. '9'] <> ['a' .. 'f'] <> ['A' .. 'F']))+ $ \c -> digitToIntMay c == Just (digitToInt c)++ prop "agrees with isHexDigit on validity" $ \c ->+ isJust (digitToIntMay c) == isHexDigit c++ prop "returns values in range 0-15 for valid inputs"+ . forAll (elements (['0' .. '9'] <> ['a' .. 'f'] <> ['A' .. 'F']))+ $ \c -> case digitToIntMay c of+ Just n -> n >= 0 && n <= 15+ Nothing -> False++ prop "lowercase and uppercase give same result" . forAll (elements ['a' .. 'f']) $ \c ->+ digitToIntMay c == digitToIntMay (toUpper c)++ describe "intToDigitMay" $ do+ describe "boundary values" $ do+ it "returns Just '0' for 0" $ do+ intToDigitMay 0 `shouldBe` Just '0'++ it "returns Just 'f' for 15" $ do+ intToDigitMay 15 `shouldBe` Just 'f'++ it "returns Nothing for -1" $ do+ intToDigitMay (-1) `shouldBe` Nothing++ it "returns Nothing for 16" $ do+ intToDigitMay 16 `shouldBe` Nothing++ describe "all valid values (0-15)" $ do+ it "returns Just for all values in range" $ do+ let validRange = [0 .. 15]+ forM_ validRange $ \n ->+ shouldBeJust (intToDigitMay n)++ it "matches intToDigit for all valid values" $ do+ let validRange = [0 .. 15]+ forM_ validRange $ \n ->+ intToDigitMay n `shouldBe` Just (intToDigit n)++ describe "QuickCheck properties" $ do+ prop "returns Just for values in range 0-15" . forAll (choose (0, 15)) $ \n ->+ isJust (intToDigitMay n)++ prop "returns Nothing for negative values" . forAll (choose (-1000, -1)) $ \n ->+ isNothing (intToDigitMay n)++ prop "returns Nothing for values greater than 15" . forAll (choose (16, 1000)) $ \n ->+ isNothing (intToDigitMay n)++ prop "matches intToDigit for all valid inputs" . forAll (choose (0, 15)) $ \n ->+ intToDigitMay n == Just (intToDigit n)++ prop "produces lowercase hex digits for 10-15" . forAll (choose (10, 15)) $ \n ->+ case intToDigitMay n of+ Just c -> c `elem` ['a' .. 'f']+ Nothing -> False++ prop "produces decimal digits for 0-9" . forAll (choose (0, 9)) $ \n ->+ case intToDigitMay n of+ Just c -> c `elem` ['0' .. '9']+ Nothing -> False++ describe "chrMay" $ do+ describe "boundary values" $ do+ it "returns Just for 0 (NUL)" $ do+ chrMay 0 `shouldBe` Just '\0'++ it "returns Just 'A' for 65" $ do+ chrMay 65 `shouldBe` Just 'A'++ it "returns Just for max valid code point (0x10FFFF)" $ do+ chrMay 0x10FFFF `shouldBe` Just '\x10FFFF'++ it "returns Nothing for -1" $ do+ chrMay (-1) `shouldBe` Nothing++ it "returns Nothing for 0x110000 (beyond max)" $ do+ chrMay 0x110000 `shouldBe` Nothing++ it "returns Nothing for surrogate start (0xD800)" $ do+ chrMay 0xD800 `shouldBe` Nothing++ it "returns Nothing for surrogate end (0xDFFF)" $ do+ chrMay 0xDFFF `shouldBe` Nothing++ it "returns Nothing for surrogate middle (0xDC00)" $ do+ chrMay 0xDC00 `shouldBe` Nothing++ describe "valid ranges" $ do+ it "returns Just for code points before surrogate range" $ do+ shouldBeJust (chrMay 0xD7FF)++ it "returns Just for code points after surrogate range" $ do+ shouldBeJust (chrMay 0xE000)++ it "returns Just for common characters" $ do+ forM_ [('a', 97), ('z', 122), ('0', 48), ('9', 57)] $ \(expected, n) ->+ chrMay n `shouldBe` Just expected++ describe "QuickCheck properties" $ do+ prop "returns Just for valid BMP code points (excluding surrogates)"+ . forAll (choose (0, 0xD7FF))+ $ \n -> isJust (chrMay n)++ prop "returns Just for valid code points after surrogates"+ . forAll (choose (0xE000, 0x10FFFF))+ $ \n -> isJust (chrMay n)++ prop "returns Nothing for surrogate range" . forAll (choose (0xD800, 0xDFFF)) $ \n ->+ isNothing (chrMay n)++ prop "returns Nothing for negative values" . forAll (choose (-1000, -1)) $ \n ->+ isNothing (chrMay n)++ prop "returns Nothing for values beyond max code point"+ . forAll (choose (0x110000, 0x200000))+ $ \n -> isNothing (chrMay n)++ prop "matches chr for all valid inputs" . forAll (choose (0, 0xD7FF)) $ \n ->+ chrMay n == Just (chr n)++ prop "is inverse of ord for valid characters" $ \c ->+ chrMay (ord c) == Just c++ prop "never throws an exception for any Int value" . withNumTests 10000 $ \n ->+ case chrMay n of+ Just _ -> True+ Nothing -> True++#if !MIN_VERSION_QuickCheck(2,18,0)+-- | `withNumTests`は`QuickCheck 2.18.0.0`で、+-- `withMaxSuccess`から改名された関数です。+-- それより古いQuickCheckには存在しないため、+-- `withMaxSuccess`で互換定義します。+withNumTests :: (Testable prop) => Int -> prop -> Property+withNumTests = withMaxSuccess+#endif
+ test/Spec/Himari/Env/SimpleSpec.hs view
@@ -0,0 +1,97 @@+{-# LANGUAGE TemplateHaskell #-}++module Spec.Himari.Env.SimpleSpec (tests) where++import Himari++-- sandwichの`logError`はTemplate Haskellを使わない別の関数で、+-- `Himari`がre-exportしているmonad-loggerの`logError`と名前が衝突します。+import Test.Sandwich hiding (logError)++tests :: TopSpec+tests = describe "Simple" $ do+ -- テスト実行時に実際のターミナルへログを出力すると、+ -- Errorなどがログディスプレイでハイライトされて紛らわしいので、+ -- ログの出力を検証しないテストでは`runSimpleNoLogEnv`で出力を破棄する。+ describe "logging" $ do+ it "outputs debug level logs" . runSimpleNoLogEnv $ do+ $(logDebug) "debug message"++ it "outputs info level logs" . runSimpleNoLogEnv $ do+ $(logInfo) "info message"++ it "outputs warning level logs" . runSimpleNoLogEnv $ do+ $(logWarn) "warning message"++ it "outputs error level logs" . runSimpleNoLogEnv $ do+ $(logError) "error message"++ it "handles multiple log calls" . runSimpleNoLogEnv $ do+ $(logInfo) "first log"+ $(logInfo) "second log"+ $(logDebug) "third log"++ it "works with monadic composition" $ do+ result <- runSimpleNoLogEnv $ do+ $(logInfo) "starting computation"+ let x = 20 :: Int+ $(logDebug) ("intermediate value: " <> convert (show x))+ let y = x + 22+ $(logInfo) "computation complete"+ pure y+ result `shouldBe` 42++ it "supports monad-logger functions" . runSimpleNoLogEnv $ do+ logInfoN "using logInfoN"+ logDebugN "using logDebugN"+ logWarnN "using logWarnN"++ describe "custom log output" $ do+ it "can capture log messages" $ do+ chan :: TChan Text <- newTChanIO+ let customLogOutput _loc _src _level msg = do+ let msgText = convert (fromLogStr msg)+ atomically $ writeTChan chan msgText+ runSimpleEnvWith customLogOutput $ do+ $(logInfo) "custom output test"+ message <- atomically $ readTChan chan+ message `shouldBe` "custom output test"++ it "captures log level information" $ do+ chan :: TChan (Text, LogLevel) <- newTChanIO+ let customLogOutput _loc _src level msg = do+ let msgText = convert (fromLogStr msg)+ atomically $ writeTChan chan (msgText, level)+ runSimpleEnvWith customLogOutput $ do+ $(logError) "error log"+ $(logWarn) "warning log"+ msg1 <- atomically $ readTChan chan+ msg2 <- atomically $ readTChan chan+ [msg1, msg2] `shouldBe` [("error log", LevelError), ("warning log", LevelWarn)]++ describe "basic execution" $ do+ it "executes actions successfully" $ do+ result <- runSimpleEnv $ pure (42 :: Int)+ result `shouldBe` 42++ it "can access and use the environment" $ do+ result <- runSimpleNoLogEnv $ do+ $(logInfo) "computing result"+ pure (10 + 32 :: Int)+ result `shouldBe` 42++ describe "Magnify instance" $ do+ it "works with magnify to access a sub-environment" $ do+ let+ -- 小さな環境 (Text) を要求するアクション+ subAction :: Himari Text Text+ subAction = do+ env <- ask+ pure $ env <> " world"+ -- 大きな環境 (Int, Text)+ bigEnv :: (Int, Text)+ bigEnv = (100, "hello")+ -- (Int, Text) の環境下で、_2 レンズを使って Text にズームして実行+ -- これがコンパイル・実行できれば Effect IO へのマッピングは成功している+ result <- runHimari bigEnv $ magnify _2 subAction+ result `shouldBe` "hello world"
+ test/Spec/Himari/Prelude/FunctorSpec.hs view
@@ -0,0 +1,41 @@+-- | Tests for functor-related re-exports in Himari.Prelude.+module Spec.Himari.Prelude.FunctorSpec (tests) where++import Data.Text qualified as T+import Himari+import Test.Sandwich++tests :: TopSpec+tests = describe "Functor" $ do+ describe "Data.Bifunctor" $ do+ it "bimap is available and works correctly" $ do+ bimap (+ 1) (* 2) (Left 5 :: Either Int Int) `shouldBe` Left 6+ bimap (+ 1) (* 2) (Right 3 :: Either Int Int) `shouldBe` Right 6++ it "bifunctorインスタンスが使える" $ do+ bimap (convert . show) T.length (42 :: Int, "hello") `shouldBe` ("42" :: Text, 5 :: Int)++ describe "Data.Functor.Const" $ do+ it "Const functor is available" $ do+ let x = Const 42 :: Const Int Text+ getConst x `shouldBe` (42 :: Int)++ it "Const functor maps correctly (ignores function)" $ do+ let x = Const 42 :: Const Int Text+ let y = fmap (const ("ignored" :: Text)) x+ getConst y `shouldBe` (42 :: Int)++ describe "Data.Functor.Identity" $ do+ it "Identity functor is available" $ do+ let x = Identity (42 :: Int)+ runIdentity x `shouldBe` (42 :: Int)++ it "Identity functor maps correctly" $ do+ let x = Identity (5 :: Int)+ let y = fmap (* 2) x+ runIdentity y `shouldBe` (10 :: Int)++ it "Identity applicative works" $ do+ let f = Identity ((+ 1) :: Int -> Int)+ let x = Identity (10 :: Int)+ runIdentity (f <*> x) `shouldBe` (11 :: Int)
+ test/Spec/HlintBaseSpec.hs view
@@ -0,0 +1,49 @@+module Spec.HlintBaseSpec (tests) where++import Himari+import HlintRunner+import Test.Sandwich++tests :: TopSpec+tests = do+ describe "hlint base library rules" . withSample "BasePartial.hs" $ do+ describe "Data.List partial functions" $ do+ it "head through Himari should warn (partial function)" $+ shouldWarnFunction "useHead" "head" "headMay"++ it "Data.List.head should warn (partial function)" $+ shouldWarnFunction "useHeadQualified" "L.head" "headMay"++ describe "NonEmpty.head should be safe" $ do+ it "Data.List.NonEmpty.head should NOT warn (it's safe)" $+ shouldNotWarnFunctionIn "useNonEmptyHead"++ describe "Debug.Trace functions suggest pTrace*" $ do+ it "Debug.Trace.trace should suggest pTrace" $+ shouldSuggestIn "useTrace" "Use pTrace"++ it "Debug.Trace.traceShow should suggest pTraceShow" $+ shouldSuggestIn "useTraceShow" "Use pTraceShow"++ it "Debug.Trace.traceM should suggest pTraceM" $+ shouldSuggestIn "useTraceM" "Use pTraceM"++ describe "Numeric integer-showing functions are partial" $ do+ it "showHex should warn (partial function)" $+ shouldWarnFunction "useShowHex" "showHex" "non-negative"++ it "showInt should warn (partial function)" $+ shouldWarnFunction "useShowInt" "showInt" "non-negative"++ it "showOct should warn (partial function)" $+ shouldWarnFunction "useShowOct" "showOct" "non-negative"++ it "showBin should warn (partial function)" $+ shouldWarnFunction "useShowBin" "showBin" "non-negative"++ it "showIntAtBase should warn (partial function)" $+ shouldWarnFunction "useShowIntAtBase" "showIntAtBase" "base > 1"++ describe "Data.Char partial functions" $ do+ it "intToDigit should warn (partial function)" $+ shouldWarnFunction "useShowIntAtBase" "intToDigit" "intToDigitMay"
+ test/Spec/HlintExtensionSpec.hs view
@@ -0,0 +1,19 @@+module Spec.HlintExtensionSpec (tests) where++import Himari+import HlintRunner+import Test.Sandwich++tests :: TopSpec+tests = do+ describe "hlint extension restriction rules" . withSample "ExtensionDangerous.hs" $ do+ describe "Dangerous extensions" $ do+ it "AllowAmbiguousTypes should warn" $+ shouldWarnExtension "AllowAmbiguousTypes"++ describe "Discouraged extensions" $ do+ it "ImplicitParams should warn" $+ shouldWarnExtension "ImplicitParams"++ it "UndecidableInstances should warn" $+ shouldWarnExtension "UndecidableInstances"
+ test/Spec/HlintReexportSpec.hs view
@@ -0,0 +1,259 @@+module Spec.HlintReexportSpec (tests) where++import Data.Set qualified as Set+import Data.Text qualified as T+import Himari+import HlintRunner+import Test.Sandwich++tests :: TopSpec+tests = do+ describe "hlint rules for symbols re-exported through himari" $ do+ describe "rules in .hlint.yaml" . withRestrictedFunctionNames $ do+ it "rules for Himari should be exactly the tested functions" $ do+ names <- getContext restrictedFunctionNames+ rulesThrough "Himari" names `shouldBe` reexportedFunctionNames++ it "rules for Himari.Prelude should be exactly the tested functions" $ do+ names <- getContext restrictedFunctionNames+ rulesThrough "Himari.Prelude" names `shouldBe` reexportedFunctionNames++ it "rules for Himari.SafePrelude should leave out the functions it lacks" $ do+ names <- getContext restrictedFunctionNames+ rulesThrough "Himari.SafePrelude" names+ `shouldBe` (reexportedFunctionNames `Set.difference` preludeOnlyFunctionNames)++ describe "import Himari" . withSample "ReexportHimari.hs" $ do+ describe "every restricted function re-exported by Himari should warn" $ do+ forM_ reexportedRestrictedFunctions $ \(declName, function, fragment) ->+ it (convert function <> " should warn with its own message") $+ shouldWarnFunction declName function fragment++ describe "functions restricted by a rule without a module name should warn" $ do+ it "throwString should warn" $+ shouldWarnFunction "useThrowString" "throwString" "typed exceptions with throwM"++ describe "functions of both Data.List and Data.Foldable should have a single message" $ do+ it "every function should be among the tested functions" $+ fmap snd listAndFoldableFunctions `shouldBe` listAndFoldableFunctionNames++ forM_ listAndFoldableFunctions $ \(declName, function) ->+ it (convert function <> " should not have concatenated messages") $+ shouldWarnFunctionOnce declName function "Partial:"++ describe "total alternatives should NOT warn" $ do+ it "headMay should NOT warn" $+ shouldNotWarnFunctionIn "useHeadMay"++ it "fromMaybe should NOT warn" $+ shouldNotWarnFunctionIn "useFromMaybe"++ describe "UnliftIO versions exported by Himari should NOT warn" $ do+ forM_ unliftioDeclarations $ \declName ->+ it (convert declName <> " should NOT warn") $+ shouldNotWarnFunctionIn declName++ describe "import Himari.Prelude" . withSample "ReexportHimariPrelude.hs" $ do+ it "head should warn" $+ shouldWarnFunction "useHead" "head" "headMay"++ it "foldl1 should warn with a single message" $+ shouldWarnFunctionOnce "useFoldl1" "foldl1" "Partial:"++ it "bifoldl1 should warn" $+ shouldWarnFunction "useBifoldl1" "bifoldl1" "bifoldl with a default value"++ it "fromJust should warn" $+ shouldWarnFunction "useFromJust" "fromJust" "fromMaybe"++ it "readFile should warn" $+ shouldWarnFunction "useReadFile" "readFile" "Lazy IO"++ it "singular should warn" $+ shouldWarnFunction "useSingular" "singular" "(^?)"++ it "stringException should warn" $+ shouldWarnFunction+ "useStringException"+ "stringException"+ "Define a proper exception type"++ it "headMay should NOT warn" $+ shouldNotWarnFunctionIn "useHeadMay"++ it "catch of UnliftIO should NOT warn" $+ shouldNotWarnFunctionIn "useCatch"++ describe "import Himari.SafePrelude" . withSample "ReexportSafePrelude.hs" $ do+ it "head should warn" $+ shouldWarnFunction "useHead" "head" "headMay"++ it "foldl1 should warn with a single message" $+ shouldWarnFunctionOnce "useFoldl1" "foldl1" "Partial:"++ it "bifoldl1 should warn" $+ shouldWarnFunction "useBifoldl1" "bifoldl1" "bifoldl with a default value"++ it "fromJust should warn" $+ shouldWarnFunction "useFromJust" "fromJust" "fromMaybe"++ it "readFile should warn" $+ shouldWarnFunction "useReadFile" "readFile" "Lazy IO"++ it "singular should warn" $+ shouldWarnFunction "useSingular" "singular" "(^?)"++ it "headMay should NOT warn" $+ shouldNotWarnFunctionIn "useHeadMay"++ describe "import forms of Himari" . withSample "ReexportImportForms.hs" $ do+ it "head qualified with the alias of Himari should warn" $+ shouldWarnFunction "useQualifiedHead" "H.head" "headMay"++ it "readFile qualified with the alias of Himari should warn" $+ shouldWarnFunction "useQualifiedReadFile" "H.readFile" "Lazy IO"++ it "tail should warn even though other names are hidden" $+ shouldWarnFunction "useTail" "tail" "tailMay"++ it "head of Data.List.NonEmpty should NOT warn when hidden from Himari" $+ shouldNotWarnFunctionIn "useNonEmptyHead"++ it "head qualified with Data.List.NonEmpty should NOT warn" $+ shouldNotWarnFunctionIn "useNonEmptyHeadQualified"++ it "definition of a user function named last should NOT warn" $+ shouldNotWarnFunctionIn "last"++ it "use of a user function named last should NOT warn" $+ shouldNotWarnFunctionIn "useOwnLast"++ describe "explicit import list of Himari" . withSample "ReexportExplicitImport.hs" $ do+ it "head should warn" $+ shouldWarnFunction "useHead" "head" "headMay"++ it "readFile should warn" $+ shouldWarnFunction "useReadFile" "readFile" "Lazy IO"++ it "headMay should NOT warn" $+ shouldNotWarnFunctionIn "useHeadMay"++-- | Label of the names shared by 'withRestrictedFunctionNames'.+restrictedFunctionNames :: Label "restrictedFunctionNames" [Text]+restrictedFunctionNames = Label++-- | Read the names of the functions restricted by @.hlint.yaml@ once+-- and share them among the tests.+withRestrictedFunctionNames+ :: SpecFree (LabelValue "restrictedFunctionNames" [Text] :> context) IO ()+ -> SpecFree context IO ()+withRestrictedFunctionNames =+ introduce+ "restricted function names of .hlint.yaml"+ restrictedFunctionNames+ loadRestrictedFunctionNames+ (const (pure ()))++-- | Module qualified names of the rules for the functions re-exported through the module.+-- Rules for the modules below it, such as @Himari.Prelude.head@ for @Himari@, are left out.+-- This does not support operators that contain a dot.+rulesThrough :: Text -> [Text] -> Set.Set Text+rulesThrough reexporter ruleNames =+ Set.fromList+ [ function+ | ruleName <- ruleNames+ , Just function <- [T.stripPrefix (reexporter <> ".") ruleName]+ , not ("." `T.isInfixOf` function)+ ]++-- | Names of the functions in 'reexportedRestrictedFunctions'.+reexportedFunctionNames :: Set.Set Text+reexportedFunctionNames =+ Set.fromList [function | (_, function, _) <- reexportedRestrictedFunctions]++-- | Functions re-exported by "Himari.Prelude" but not by "Himari.SafePrelude".+preludeOnlyFunctionNames :: Set.Set Text+preludeOnlyFunctionNames = Set.fromList ["stringException"]++-- | Declarations of the sample paired with the restricted function they use+-- and a fragment of the message of its rule.+-- These are all the functions that have a rule qualified with a module of himari in @.hlint.yaml@,+-- which is verified against @.hlint.yaml@ by the tests.+-- They are re-exported by "Himari" as the very same entity as the original one.+reexportedRestrictedFunctions :: [(Text, Text, Text)]+reexportedRestrictedFunctions =+ [ ("useHead", "head", "headMay")+ , ("useTail", "tail", "tailMay")+ , ("useInit", "init", "initMay")+ , ("useLast", "last", "lastMay")+ , ("useCycle", "cycle", "cycleMay")+ , ("useScanl1", "scanl1", "scanl1May")+ , ("useScanr1", "scanr1", "scanr1May")+ , ("useFoldl1", "foldl1", "foldl1May from Safe.Foldable")+ , ("useFoldr1", "foldr1", "foldr1May from Safe.Foldable")+ , ("useMaximum", "maximum", "maximumMay or maximumBound from Safe.Foldable")+ , ("useMinimum", "minimum", "minimumMay or minimumBound from Safe.Foldable")+ , ("useMaximumBy", "maximumBy", "maximumByMay or maximumBoundBy from Safe.Foldable")+ , ("useMinimumBy", "minimumBy", "minimumByMay or minimumBoundBy from Safe.Foldable")+ , ("useBifoldl1", "bifoldl1", "bifoldl with a default value")+ , ("useBifoldr1", "bifoldr1", "bifoldr with a default value")+ , ("useBimaximum", "bimaximum", "bifoldr with explicit initial value")+ , ("useBiminimum", "biminimum", "bifoldr with explicit initial value")+ , ("useBimaximumBy", "bimaximumBy", "bifoldr with explicit initial value")+ , ("useBiminimumBy", "biminimumBy", "bifoldr with explicit initial value")+ , ("useFromJust", "fromJust", "fromMaybe")+ , ("useGetChar", "getChar", "Encoding depends on LANG")+ , ("useGetLine", "getLine", "Encoding depends on LANG")+ , ("useGetContents", "getContents", "Use strict Text or ByteString")+ , ("useInteract", "interact", "Lazy IO + env-dependent encoding.")+ , ("useReadIO", "readIO", "partial (uses read)")+ , ("useReadLn", "readLn", "partial (uses read)")+ , ("usePutChar", "putChar", "Encoding depends on LANG")+ , ("usePutStr", "putStr", "Encoding depends on LANG")+ , ("usePutStrLn", "putStrLn", "Encoding depends on LANG")+ , ("usePrint", "print", "Encoding depends on LANG")+ , ("useReadFile", "readFile", "Data.Text.IO.readFile")+ , ("useWriteFile", "writeFile", "Data.Text.IO.writeFile")+ , ("useAppendFile", "appendFile", "Data.Text.IO.appendFile")+ , ("useSingular", "singular", "(^?)")+ , ("useUnsafeSingular", "unsafeSingular", "0 or >1 elements")+ , ("useUnsafePartsOf", "unsafePartsOf", "list length changes")+ , ("useIunsafePartsOf", "iunsafePartsOf", "list length changes")+ , ("useStringException", "stringException", "Define a proper exception type")+ ]++-- | Functions that both "Data.List" and "Data.Foldable" export as the very same entity.+-- Both modules have a rule for them, so their messages are prone to be concatenated.+-- The declarations that use them are looked up in 'reexportedRestrictedFunctions'.+listAndFoldableFunctions :: [(Text, Text)]+listAndFoldableFunctions =+ [ (declName, function)+ | (declName, function, _) <- reexportedRestrictedFunctions+ , function `elem` listAndFoldableFunctionNames+ ]++-- | Names of the functions in 'listAndFoldableFunctions'.+listAndFoldableFunctionNames :: [Text]+listAndFoldableFunctionNames =+ [ "foldl1"+ , "foldr1"+ , "maximum"+ , "minimum"+ , "maximumBy"+ , "minimumBy"+ ]++-- | Declarations of the sample that use the UnliftIO version of a name+-- whose non-UnliftIO version has a rule in @.hlint.yaml@.+unliftioDeclarations :: [Text]+unliftioDeclarations =+ [ "useCatch"+ , "useBracket"+ , "useFinally"+ , "useTry"+ , "useWithMVar"+ , "useModifyMVar"+ , "useTimeout"+ , "useMyThreadId"+ , "useDoesFileExist"+ ]
+ test/Spec/HlintUnliftioSpec.hs view
@@ -0,0 +1,33 @@+module Spec.HlintUnliftioSpec (tests) where++import Himari+import HlintRunner+import Test.Sandwich++tests :: TopSpec+tests = do+ describe "hlint unliftio preference rules" . withSample "UnliftioPreference.hs" $ do+ describe "Control" $ do+ describe "Exception" $ do+ it "catch should warn to use UnliftIO.Exception" $+ shouldWarnFunction "badCatch" "Exception.catch" "UnliftIO.Exception.catch"++ it "bracket should warn to use UnliftIO.Exception" $+ shouldWarnFunction "badBracket" "Exception.bracket" "UnliftIO.Exception.bracket"++ it "finally should warn to use UnliftIO.Exception" $+ shouldWarnFunction "badFinally" "Exception.finally" "UnliftIO.Exception.finally"++ it "try should warn to use UnliftIO.Exception" $+ shouldWarnFunction "badTry" "Exception.try" "UnliftIO.Exception.try"++ describe "Concurrent.MVar" $ do+ it "withMVar should warn to use UnliftIO.MVar" $+ shouldWarnFunction "badWithMVar" "MVar.withMVar" "UnliftIO.MVar.withMVar"++ it "modifyMVar_ should warn to use UnliftIO.MVar" $+ shouldWarnFunction "badModifyMVar" "MVar.modifyMVar_" "UnliftIO.MVar.modifyMVar_"++ describe "System.Timeout" $ do+ it "timeout should warn to use UnliftIO.Timeout" $+ shouldWarnFunction "badTimeout" "Timeout.timeout" "UnliftIO.Timeout.timeout"
+ test/Spec/TitleSpec.hs view
@@ -0,0 +1,32 @@+module Spec.TitleSpec (tests) where++import Data.List.NonEmpty qualified as NE+import Himari+import Himari.Title+import Test.Sandwich++tests :: TopSpec+tests = describe "Title" $ do+ describe "titleComponents" $ do+ it "最初の要素が「超」であること" $ do+ NE.head titleComponents `shouldBe` "超"++ it "6つの要素を持つこと" $ do+ length titleComponents `shouldBe` 6++ describe "generateAllCombinations" $ do+ it "空でないリストを生成すること" $ do+ generateAllCombinations `shouldNotBe` []++ it "各組み合わせが空でないこと" $ do+ any null generateAllCombinations `shouldBe` False++ describe "renderTitle" $ do+ it "単一要素の肩書きを正しく変換すること" $ do+ renderTitle ("超" NE.:| []) `shouldBe` "超"++ it "複数要素の肩書きを連結すること" $ do+ renderTitle ("超" NE.:| ["天才"]) `shouldBe` "超天才"++ it "全要素を連結すること" $ do+ renderTitle titleComponents `shouldBe` "超天才清楚系病弱美少女ハッカー"
− test/TitleSpec.hs
@@ -1,32 +0,0 @@-module TitleSpec (spec) where--import Data.List.NonEmpty qualified as NE-import Himari-import Himari.Title-import Test.Syd--spec :: Spec-spec = do- describe "titleComponents" $ do- it "最初の要素が「超」であること" $ do- NE.head titleComponents `shouldBe` "超"-- it "6つの要素を持つこと" $ do- length titleComponents `shouldBe` 6-- describe "generateAllCombinations" $ do- it "空でないリストを生成すること" $ do- generateAllCombinations `shouldNotSatisfy` null-- it "各組み合わせが空でないこと" $ do- any null generateAllCombinations `shouldBe` False-- describe "renderTitle" $ do- it "単一要素の肩書きを正しく変換すること" $ do- renderTitle ("超" NE.:| []) `shouldBe` "超"-- it "複数要素の肩書きを連結すること" $ do- renderTitle ("超" NE.:| ["天才"]) `shouldBe` "超天才"-- it "全要素を連結すること" $ do- renderTitle titleComponents `shouldBe` "超天才清楚系病弱美少女ハッカー"