Remove the intermediary list

This commit is contained in:
Mats Rauhala 2019-01-02 19:05:44 +02:00
parent 22c19d0729
commit 4139562a49

View File

@ -57,9 +57,8 @@ main :: IO ()
main = do main = do
Cmd{..} <- getRecord "Image duplicate finder" Cmd{..} <- getRecord "Image duplicate finder"
-- XXX: This is a really long line, split it up -- XXX: This is a really long line, split it up
fingerprints <- runSafeT (P.fold (\acc -> either (const acc) (\x -> x `seq` x : acc)) [] id (find source (glob "*.jpg" <> regular) >-> P.mapM (\path -> liftIO (putStrLn path) >> fmap (path,) <$> liftIO (readImage path)) >-> P.map (fmap (\(path, img) -> Fingerprint path (fingerprint img))))) index <- runSafeT (P.fold (\acc -> either (const acc) (\x -> x `seq` BK.insert x acc)) BK.empty id (find source (glob "*.jpg" <> regular) >-> P.mapM (\path -> liftIO (putStrLn path) >> fmap (path,) <$> liftIO (readImage path)) >-> P.map (fmap (\(path, img) -> Fingerprint path (fingerprint img)))))
let index = foldl' (flip BK.insert) BK.empty fingerprints forM_ index $ \fp -> do
forM_ fingerprints $ \fp -> do
let similar = BK.search 1 fp index let similar = BK.search 1 fp index
when (length similar > 1) $ do when (length similar > 1) $ do
print similar print similar