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
45

import Data.Maybe (catMaybes)
foo :: [(Int, Int)]
foo = [(8, 14), (4,2), (3,4)]
findmin :: (Int, Int) > (Int, Int) > (Int, Int)
findmin (a,b) (c,d)
 a < c = (a,b)
 otherwise = (c,d)
minf :: [(Int, Int)] > (Int, Int)
minf (x:xs) = foldr findmin x xs
minf2 :: [(Int, Int)] > Int
minf2 xs = b
where (a,b) = minf xs
data Bar = Bar Int Int deriving (Eq,Show)
instance Ord Bar where
(Bar _ s1) `compare` (Bar _ s2) = s1 `compare` s2
 Stuff with applicative
intlist = [1, 5, 6, 8]
func1 x = x * 2
func2 x = x * 3
func3 x = x * 5
funcs = [func1, func2, func3]
maybeints = [ Just 1, Just 2, Nothing, Just 4]
lift_tuple :: (Int, Maybe Int) > Maybe (Int, Int)
lift_tuple (a, Just b) = Just (a, b)
lift_tuple (a, Nothing) = Nothing
pairs = catMaybes $ map lift_tuple $ zip intlist maybeints
