From 3b8845f4d5acbfb465dba5b282fca6f750d410b9 Mon Sep 17 00:00:00 2001 From: Anton-Latukha Date: Tue, 9 Feb 2021 00:22:07 +0200 Subject: [PATCH] remaining map -> fmap --- main/Repl.hs | 2 +- tests/NixLanguageTests.hs | 4 ++-- tests/ParserTests.hs | 2 +- tests/PrettyParseTests.hs | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/main/Repl.hs b/main/Repl.hs index 03abff344..a35946d33 100644 --- a/main/Repl.hs +++ b/main/Repl.hs @@ -100,7 +100,7 @@ main' iniVal = initState iniVal >>= \s -> flip evalStateT s rcFile = do f <- liftIO $ Data.Text.IO.readFile ".hnixrc" `catch` handleMissing - forM_ (map (words . Data.Text.unpack) $ Data.Text.lines f) $ \case + forM_ (fmap (words . Data.Text.unpack) $ Data.Text.lines f) $ \case ((prefix:command) : xs) | prefix == commandPrefix -> do let arguments = unwords xs optMatcher command options arguments diff --git a/tests/NixLanguageTests.hs b/tests/NixLanguageTests.hs index e132fe613..c479eeb99 100644 --- a/tests/NixLanguageTests.hs +++ b/tests/NixLanguageTests.hs @@ -158,7 +158,7 @@ assertEval _opts files = do Opts.execParserPure Opts.defaultPrefs (nixOptionsInfo time) - (fixup (map Text.unpack (Text.splitOn " " flags'))) + (fixup (fmap Text.unpack (Text.splitOn " " flags'))) of Opts.Failure err -> errorWithoutStackTrace @@ -171,7 +171,7 @@ assertEval _opts files = do _ -> assertFailure $ "Unknown test type " ++ show files where name = - "data/nix/tests/lang/" ++ the (map (takeFileName . dropExtensions) files) + "data/nix/tests/lang/" ++ the (fmap (takeFileName . dropExtensions) files) fixup ("--arg" : x : y : rest) = "--arg" : (x ++ "=" ++ y) : fixup rest fixup ("--argstr" : x : y : rest) = "--argstr" : (x ++ "=" ++ y) : fixup rest diff --git a/tests/ParserTests.hs b/tests/ParserTests.hs index 0439b4075..8df480f6c 100644 --- a/tests/ParserTests.hs +++ b/tests/ParserTests.hs @@ -122,7 +122,7 @@ case_inherit_selector = do case_int_list = assertParseText "[1 2 3]" $ Fix $ NList [ mkInt i | i <- [1,2,3] ] -case_int_null_list = assertParseText "[1 2 3 null 4]" $ Fix (NList (map (Fix . NConstant) [NInt 1, NInt 2, NInt 3, NNull, NInt 4])) +case_int_null_list = assertParseText "[1 2 3 null 4]" $ Fix (NList (fmap (Fix . NConstant) [NInt 1, NInt 2, NInt 3, NNull, NInt 4])) case_mixed_list = do assertParseText "[{a = 3;}.a (if true then null else false) null false 4 [] c.d or null]" $ Fix $ NList diff --git a/tests/PrettyParseTests.hs b/tests/PrettyParseTests.hs index 026be2ae6..3426bfe04 100644 --- a/tests/PrettyParseTests.hs +++ b/tests/PrettyParseTests.hs @@ -148,8 +148,8 @@ normalize = foldFix $ \case NConstant (NFloat n) | n < 0 -> Fix (NUnary NNeg (Fix (NConstant (NFloat (negate n))))) - NSet recur binds -> Fix (NSet recur (map normBinding binds)) - NLet binds r -> Fix (NLet (map normBinding binds) r) + NSet recur binds -> Fix (NSet recur (fmap normBinding binds)) + NLet binds r -> Fix (NLet (fmap normBinding binds) r) NAbs params r -> Fix (NAbs (normParams params) r) @@ -157,7 +157,7 @@ normalize = foldFix $ \case where normBinding (NamedVar path r pos) = NamedVar (NE.map normKey path) r pos - normBinding (Inherit mr names pos) = Inherit mr (map normKey names) pos + normBinding (Inherit mr names pos) = Inherit mr (fmap normKey names) pos normKey (DynamicKey quoted) = DynamicKey (normAntiquotedString quoted) normKey (StaticKey name ) = StaticKey name @@ -220,7 +220,7 @@ prop_prettyparse p = do normalise = unlines . fmap (reverse . dropWhile isSpace . reverse) . lines ldiff :: String -> String -> [Diff [String]] - ldiff s1 s2 = getDiff (map (: []) (lines s1)) (map (: []) (lines s2)) + ldiff s1 s2 = getDiff (fmap (: []) (lines s1)) (fmap (: []) (lines s2)) tests :: TestLimit -> TestTree tests n = testProperty "Pretty/Parse Property" $ withTests n $ property $ do