diff options
author | Yann Herklotz <git@ymhg.org> | 2019-04-02 14:48:53 +0100 |
---|---|---|
committer | Yann Herklotz <git@ymhg.org> | 2019-04-02 14:48:53 +0100 |
commit | 1ef0455ddad821c2ddf64d451e99b8b5508c39c5 (patch) | |
tree | 38d16266885732d524781ebd31658a50f0bedf4e /src/VeriFuzz | |
parent | 372bcb00204d225f4b89cfed33f99a519740dc8e (diff) | |
download | verismith-1ef0455ddad821c2ddf64d451e99b8b5508c39c5.tar.gz verismith-1ef0455ddad821c2ddf64d451e99b8b5508c39c5.zip |
Fix hlint hints
Diffstat (limited to 'src/VeriFuzz')
-rw-r--r-- | src/VeriFuzz/Config.hs | 2 | ||||
-rw-r--r-- | src/VeriFuzz/Parser/Parser.hs | 13 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/VeriFuzz/Config.hs b/src/VeriFuzz/Config.hs index b135c55..eefebe2 100644 --- a/src/VeriFuzz/Config.hs +++ b/src/VeriFuzz/Config.hs @@ -130,7 +130,7 @@ parseConfig t = case Toml.decode configCodec t of Left (Toml.ParseError _) -> error "Config file parse error" configEncode :: Config -> Text -configEncode c = Toml.encode configCodec c +configEncode = Toml.encode configCodec configToFile :: FilePath -> Config -> IO () configToFile f = T.writeFile f . configEncode diff --git a/src/VeriFuzz/Parser/Parser.hs b/src/VeriFuzz/Parser/Parser.hs index d7dc4ee..48e92ec 100644 --- a/src/VeriFuzz/Parser/Parser.hs +++ b/src/VeriFuzz/Parser/Parser.hs @@ -23,6 +23,7 @@ module VeriFuzz.Parser.Parser where import Control.Lens +import Control.Monad (void) import Data.Functor (($>)) import Data.Functor.Identity (Identity) import qualified Data.Text as T @@ -75,7 +76,7 @@ tok t = satisfy (\(Token t' _ _) -> t' == t) <?> show t -- | Parse without returning the `TokenName`. tok' :: TokenName -> Parser () -tok' p = tok p >> return () +tok' p = void $ tok p parens :: Parser a -> Parser a parens = between (tok SymParenL) (tok SymParenR) @@ -217,17 +218,17 @@ number :: Parser Decimal number = number' <$> numLit where number' :: String -> Decimal - number' a | all (flip elem ['0' .. '9']) a = fromInteger $ read a + number' a | all (`elem` ['0' .. '9']) a = fromInteger $ read a | head a == '\'' = fromInteger $ f a - | isInfixOf "'" a = Decimal (read w) (f b) + | "'" `isInfixOf` a = Decimal (read w) (f b) | otherwise = error $ "Invalid number format: " ++ a where w = takeWhile (/= '\'') a b = dropWhile (/= '\'') a f a' - | isPrefixOf "'d" a' = read $ drop 2 a' - | isPrefixOf "'h" a' = read $ "0x" ++ drop 2 a' - | isPrefixOf "'b" a' = foldl + | "'d" `isPrefixOf` a' = read $ drop 2 a' + | "'h" `isPrefixOf` a' = read $ "0x" ++ drop 2 a' + | "'b" `isPrefixOf` a' = foldl (\n b' -> shiftL n 1 .|. (if b' == '1' then 1 else 0)) 0 (drop 2 a') |