File: LiquidSpec.hs

package info (click to toggle)
haskell-raaz 0.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 844 kB
  • sloc: haskell: 5,045; ansic: 1,885; makefile: 18
file content (41 lines) | stat: -rw-r--r-- 1,187 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import Control.Monad
import Language.Haskell.Liquid.Liquid
import System.Exit
import System.Directory
import System.FilePath

-- | Liquid haskell is run on these files/directors. If the given name
-- is a directory we recurse on all .hs/.lhs files in that directory.
toCheck :: [FilePath]
toCheck = [ "Raaz/Core/Encode"
          , "Raaz/Core/Types/Tuple.hs"
          , "Raaz/Hash/Sha1"
          , "Raaz/Hash/Sha224"
          , "Raaz/Hash/Sha256"
          , "Raaz/Hash/Sha384"
          , "Raaz/Hash/Sha512"
          ]

main :: IO ()
main = do allHsFiles toCheck >>= liquid


allHsFiles :: [FilePath] -> IO [FilePath]
allHsFiles = fmap concat . mapM allHsFile

allHsFile :: FilePath -> IO [FilePath]
allHsFile fp = doesFileExist fp >>= handleFile

  where handleFile cond
           | cond && checkHs fp = return [fp]
           | cond               = return []
           | otherwise          = doesDirectoryExist fp >>= handleDir

        handleDir cond
           | cond       = recurse
           | otherwise  = return []

        recurse = listDirectory fp >>= allHsFiles . map (fp</>)

        checkHs fp = ext == ".hs" || ext == ".lhs"
          where ext = takeExtension fp