File tree Expand file tree Collapse file tree 3 files changed +23
-12
lines changed Expand file tree Collapse file tree 3 files changed +23
-12
lines changed Original file line number Diff line number Diff line change 1
1
{-# LANGUAGE BangPatterns #-}
2
2
module Main (main ) where
3
3
4
- import Control.Monad (forM_ , when )
4
+ import Control.Monad (forM_ , unless , when )
5
5
import System.Environment (getArgs )
6
6
7
7
import qualified Data.BloomFilter as B
8
8
9
9
main :: IO ()
10
10
main = do
11
11
files <- getArgs
12
- dictionary <- readFile " /usr/share/dict/words"
13
- let ! bloom = B. fromList (B. policyForFPR 0.01 ) (words dictionary)
14
- forM_ files $ \ file ->
15
- putStrLn . unlines . filter (`B.notElem` bloom) . words
16
- =<< readFile file
12
+ unless (null files) $ do
13
+ dictionary <- readFile " /usr/share/dict/words"
14
+ let ! bloom = B. fromList (B. policyForFPR 0.01 ) (words dictionary)
15
+ forM_ files $ \ file ->
16
+ putStrLn . unlines . filter (`B.notElem` bloom) . words
17
+ =<< readFile file
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import qualified Data.IntSet as IntSet
12
12
import Data.List (unfoldr )
13
13
import Math.Regression.Simple
14
14
import System.Environment (getArgs )
15
- import System.Exit (exitFailure )
16
15
import System.IO
17
16
import System.Random
18
17
@@ -29,7 +28,8 @@ main = do
29
28
[" Regression" ] -> main_regression
30
29
_ -> do
31
30
putStrLn " Usage: bloomfilter-fpr-calc [Generate|Regression]"
32
- exitFailure
31
+ -- NOTE: we expicitly don't use exitFailure here because
32
+ -- @bloomfilter-fpr-calc@ is a cabal @test-suite@.
33
33
34
34
main_regression :: IO ()
35
35
main_regression = do
Original file line number Diff line number Diff line change @@ -692,9 +692,14 @@ benchmark bloomfilter-bench
692
692
, lsm-tree :bloomfilter
693
693
, random
694
694
695
- executable bloomfilter-fpr-calc
695
+ -- TODO: ideally this should be an executable because it's not really testing
696
+ -- anything, but if we make it an executable component then the solver takes the
697
+ -- build-depends into account when building the public library, which is not
698
+ -- desirable. Maybe these executables should be moved out into a separate
699
+ -- package?
700
+ test-suite bloomfilter-fpr-calc
696
701
import : language, warnings
697
- scope : private
702
+ type : exitcode-stdio-1.0
698
703
hs-source-dirs : bloomfilter/tests
699
704
main-is : fpr-calc.hs
700
705
build-depends :
@@ -707,9 +712,14 @@ executable bloomfilter-fpr-calc
707
712
708
713
ghc-options : -threaded
709
714
710
- executable bloomfilter-spell
715
+ -- TODO: ideally this should be an executable because it's not really testing
716
+ -- anything, but if we make it an executable component then the solver takes the
717
+ -- build-depends into account when building the public library, which is not
718
+ -- desirable. Maybe these executables should be moved out into a separate
719
+ -- package?
720
+ test-suite bloomfilter-spell
711
721
import : language
712
- scope : private
722
+ type : exitcode-stdio-1.0
713
723
hs-source-dirs : bloomfilter/examples
714
724
main-is : spell.hs
715
725
build-depends :
You can’t perform that action at this time.
0 commit comments