diff options
author | Justin Bedo <cu@cua0.org> | 2023-08-03 16:25:16 +1000 |
---|---|---|
committer | Justin Bedo <cu@cua0.org> | 2023-08-03 23:34:27 +1000 |
commit | 04685332602ebcb6c0429026aa1def55f4c8c483 (patch) | |
tree | 23dd44766e5d5206aafa9187187cae16872e3808 /dedumi.hs | |
parent | ae32b54617ab7bd5d24764d0d85a7a08a9e8d461 (diff) |
tidy code
Diffstat (limited to 'dedumi.hs')
-rw-r--r-- | dedumi.hs | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -3,6 +3,7 @@ {-# LANGUAGE NumericUnderscores #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} +{-# OPTIONS_GHC -Wno-orphans #-} module Main where @@ -11,7 +12,8 @@ import qualified Data.ByteString as B import Data.Cuckoo import Data.FastQ import Data.Function -import Data.Typeable +import GHC.Prim (RealWorld) +import GHC.TypeLits import Lens.Micro import qualified Streamly.Data.Stream as S import System.Environment @@ -22,8 +24,10 @@ instance CuckooFilterHash ByteString where {-# INLINE cuckooHash #-} {-# INLINE cuckooFingerprint #-} +umiLength :: Int umiLength = 8 +trim :: ReadPair -> ReadPair trim x = x & _1 . nucs %~ B.drop umiLength @@ -31,6 +35,7 @@ trim x = & _1 . qual %~ B.drop umiLength & _2 . qual %~ B.drop umiLength +insert' :: (KnownNat b, KnownNat f) => CuckooFilter RealWorld b f ByteString -> ReadPair -> IO Bool insert' f x = let y = B.take umiLength (x ^. _1 . nucs) <> B.take umiLength (x ^. _2 . nucs) in member f y >>= \case @@ -40,6 +45,7 @@ insert' f x = True -> pure False False -> error "filter full" +main :: IO () main = do [p1, p2, p3, p4] <- getArgs @@ -49,5 +55,3 @@ main = do & S.filterM (insert' f) & fmap trim & unparse p3 p4 - - pure () |