Merge pull request #203 from hapytex/hlint/use-fmap

make use of <$>
This commit is contained in:
Jonathan Daugherty 2021-02-16 09:44:49 -08:00 committed by GitHub
commit 572c59881b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 8 deletions

View File

@ -14,5 +14,4 @@ utf8FromIso :: [Int] -> [Word8]
utf8FromIso = encode . map toEnum
ppUtf8 :: [Int] -> IO ()
ppUtf8 = print . map (\f -> f "") . map showHex . utf8FromIso
ppUtf8 = print . map (`showHex` "") . utf8FromIso

View File

@ -42,7 +42,7 @@ pop = do
readParam :: Word -> Eval CapParam
readParam pn = do
!params <- get >>= return . evalParams
!params <- evalParams <$> get
return $! genericIndex params pn
push :: CapParam -> Eval ()
@ -68,7 +68,7 @@ writeCapOps ops = mapM_ writeCapOp ops
writeCapOp :: CapOp -> Eval ()
writeCapOp (Bytes !offset !count) = do
!cap <- get >>= return . evalExpression
!cap <- evalExpression <$> get
let bytes = Vector.take count $ Vector.drop offset (capBytes cap)
Vector.forM_ bytes $ tell.writeWord8
writeCapOp DecOut = do

View File

@ -128,7 +128,7 @@ paramEscapeParser = do
literalPercentParser :: CapParser BuildResults
literalPercentParser = do
_ <- char '%'
startOffset <- getState >>= return . nextOffset
startOffset <- nextOffset <$> getState
incOffset 1
return $ BuildResults 0 [Bytes startOffset 1] []
@ -154,7 +154,7 @@ incrementOpParser = do
pushOpParser :: CapParser BuildResults
pushOpParser = do
_ <- char 'p'
paramN <- digit >>= return . (\d -> read [d])
paramN <- read . pure <$> digit
incOffset 2
return $ BuildResults (fromEnum paramN) [PushParam $ paramN - 1] []
@ -299,7 +299,7 @@ compareOpParser
bytesOpParser :: CapParser BuildResults
bytesOpParser = do
bytes <- many1 $ satisfy (/= '%')
startOffset <- getState >>= return . nextOffset
startOffset <- nextOffset <$> getState
let !c = length bytes
!s <- getState
let s' = s { nextOffset = startOffset + c }

View File

@ -137,7 +137,7 @@ readFromDevice = do
threadWaitRead fd
bytesRead <- fdReadBuf fd bufferPtr (fromIntegral maxBytes)
if bytesRead > 0
then fmap (map $ chr . fromIntegral) $ peekArray (fromIntegral bytesRead) bufferPtr
then map (chr . fromIntegral) <$> peekArray (fromIntegral bytesRead) bufferPtr
else return []
when (not $ null stringRep) $ logMsg $ "input bytes: " ++ show stringRep
return stringRep