Skip to content

Commit 593e4e9

Browse files
committed
Go for minimal diff
1 parent 13dbda2 commit 593e4e9

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

precompute-fileinfo/src/Main.hs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
{-# LANGUAGE ScopedTypeVariables #-}
2-
31
module Main where
42

53
import Control.Concurrent
@@ -169,17 +167,14 @@ writeMap fp hashes = withFile fp WriteMode $ \h ->
169167
readMap :: FilePath -> IO (Map MD5 (SHA256, Length))
170168
readMap fp =
171169
withFile fp ReadMode $ \h -> do
172-
hashes <- mapFromParseEntry . lines <$> hGetContents h
170+
hashes <- Map.fromList . map parseEntry . lines <$> hGetContents h
173171
evaluate $ rnf hashes
174172
return hashes
175173
where
176-
mapFromParseEntry :: [String] -> Map MD5 (SHA256, Length)
177-
mapFromParseEntry mapLines = Map.fromList
178-
[ case ws of
179-
[md5, sha256, len] -> (md5, (sha256, read len))
180-
_ -> (unwords ws, undefined)
181-
| ws <- words <$> mapLines
182-
]
174+
parseEntry :: String -> (MD5, (SHA256, Length))
175+
parseEntry line = case words line of
176+
[md5, sha256, len] -> (md5, (sha256, read len))
177+
_ -> error $ "failed: parseEntry " ++ show line
183178

184179
{-------------------------------------------------------------------------------
185180
Auxiliary

0 commit comments

Comments
 (0)