diff options
-rw-r--r-- | src/VeriFuzz/Config.hs | 2 | ||||
-rw-r--r-- | src/VeriFuzz/Parser/Parser.hs | 13 | ||||
-rw-r--r-- | test/Property.hs | 4 |
3 files changed, 10 insertions, 9 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') diff --git a/test/Property.hs b/test/Property.hs index e948069..be8132b 100644 --- a/test/Property.hs +++ b/test/Property.hs @@ -48,10 +48,10 @@ parserIdempotent' = Hog.property $ do . alexScanTokens parserInput :: TestTree -parserInput = testProperty "parser input" $ parserInput' +parserInput = testProperty "parser input" parserInput' parserIdempotent :: TestTree -parserIdempotent = testProperty "parser idempotence" $ parserIdempotent' +parserIdempotent = testProperty "parser idempotence" parserIdempotent' propertyTests :: TestTree propertyTests = |