TestFun

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import Data.List 

main = print $ testFun

a = [1,1,1,1]
b = [0..3] 
c = [MyTuple (x,0) | x <- b]

testFun     = sort $ (map reduceIt aList) `union` c 
aList       = group $ sort [ x+y | x <- a, y <- b, x+y < 3 ] 
reduceIt xs = MyTuple (head xs, length xs)

data MyTuple = MyTuple {getTuple :: (Int, Int)}
               deriving Ord

instance Eq MyTuple where
  MyTuple x == MyTuple y = (fst x) == (fst y)

instance Show MyTuple where
  show (MyTuple x) = show (snd x)
3:8: Warning: Redundant $
Found:
print $ testFun
Why not:
print testFun
9:22: Warning: Redundant bracket
Found:
(map reduceIt aList) `union` c
Why not:
map reduceIt aList `union` c
17:28: Warning: Redundant bracket
Found:
(fst x) == (fst y)
Why not:
fst x == (fst y)
17:28: Warning: Redundant bracket
Found:
(fst x) == (fst y)
Why not:
(fst x) == fst y

TestFun (1)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import Data.List 

main = print testFun

a = [1,1,1,1]
b = [0..3] 
c = [MyTuple (x,0) | x <- b]

testFun     = sort $ map reduceIt aList `union` c 
aList       = group $ sort [ x+y | x <- a, y <- b, x+y < 3 ] 
reduceIt xs = MyTuple (head xs, length xs)

data MyTuple = MyTuple {getTuple :: (Int, Int)}
               deriving Ord

instance Eq MyTuple where
  MyTuple x == MyTuple y = fst x == fst y

instance Show MyTuple where
  show (MyTuple x) = show (snd x)