forked from ndmitchell/hlint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind.test
44 lines (35 loc) · 1.01 KB
/
find.test
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
42
43
44
---------------------------------------------------------------------
RUN --find=tests/find.hs
FILE tests/find.hs
{-# LANGUAGE CPP, ExistentialQuantification, Rank2Types #-}
module Util where
import Control.Arrow
import Control.Monad.Trans.State
import Data.Char
import Data.Function
listM' :: Monad m => [a] -> m [a]
listM' x = length x `seq` return x
notNull = not . null
headDef :: a -> [a] -> a
headDef x [] = x
headDef x (y:ys) = y
isLeft Left{} = True; isLeft _ = False
isRight = not . isLeft
swap :: (a,b) -> (b,a)
swap (a,b) = (b,a)
exitMessage :: String -> a
exitMessage msg = unsafePerformIO $ do
putStrLn msg
exitWith $ ExitFailure 1
defaultExtensions = knownExtensions \\ badExtensions
OUTPUT
-- hints found in tests/find.hs
warn = length a `seq` return a ==> listM' a
warn = not (null a) ==> notNull a
warn = not (isLeft a) ==> isRight a
warn
= unsafePerformIO
(do putStrLn a
exitWith (ExitFailure 1))
==> exitMessage a
warn = knownExtensions \\ badExtensions ==> defaultExtensions