λ> :t 1 1 :: Num a => a λ> :t 1.2 1.2 :: Fractional a => a λ> :t True True :: Bool λ> :t False False :: Bool λ> :t "abc" "abc" :: [Char] λ> :t 'a' 'a' :: Char λ> :t ('a', True) ('a', True) :: (Char, Bool) λ> :t [1, 2, 3] [1, 2, 3] :: Num t => [t] λ> :t (1 ,'a', True, [1,2,3]) (1 ,'a', True, [1,2,3]) :: (Num t1, Num t) => (t, Char, Bool, [t1]) λ> λ> λ> [1,2,3,4] [1,2,3,4] λ> [1..10] [1,2,3,4,5,6,7,8,9,10] λ> [1, 3..10] [1,3,5,7,9] λ> [1, 4..10] [1,4,7,10] λ> [1,1.5..10] [1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0] λ> :t [1,1.5..10] [1,1.5..10] :: (Fractional t, Enum t) => [t] λ> :i Char data Char = GHC.Types.C# GHC.Prim.Char# -- Defined in `GHC.Types' instance Bounded Char -- Defined in `GHC.Enum' instance Enum Char -- Defined in `GHC.Enum' instance Eq Char -- Defined in `GHC.Classes' instance Ord Char -- Defined in `GHC.Classes' instance Read Char -- Defined in `GHC.Read' instance Show Char -- Defined in `GHC.Show' instance Random Char -- Defined in `System.Random' λ> λ> λ> :t add1 add1 :: Integer -> Integer -> Integer λ> :t add2 add2 :: Integer -> Integer -> Integer λ> :t add3 add3 :: Integer -> Integer -> Integer λ> :r [1 of 1] Compiling Main ( PP-06-haskell-intro-s.hs, interpreted ) Ok, modules loaded: Main. λ> x 5 λ> λ> addX 1 2 3 λ> addX 4 5 9 λ> addX 2 3 *** Exception: PP-06-haskell-intro-s.hs:(18,1)-(19,12): Non-exhaustive patterns in function addX λ> :t (+) (+) :: Num a => a -> a -> a λ> :t (+ 5) (+ 5) :: Num a => a -> a λ> :t add6 add6 :: Num a => a -> a -> a λ> (1, 2) (1,2) λ> fst (1, 2) 1 λ> snd (1, 2) 2 λ> :r λ> mid3 (1, True, 'c') True λ> lst3 (1, True, 'c') 'c' λ> λ> λ> 1 : [2,3,4] [1,2,3,4] λ> :t [] [] :: [t] λ> head [1..10] 1 λ> tail [1..10] [2,3,4,5,6,7,8,9,10] λ> [1,2,3] ++ [4,5,6] [1,2,3,4,5,6] λ> [1,2,3,4,5,6,7] !! 3 4 λ> :t len1 len1 :: (Num a, Eq t) => [t] -> a λ> λ> :r [1 of 1] Compiling Main ( PP-06-haskell-intro-s.hs, interpreted ) PP-06-haskell-intro-s.hs:33:42: Couldn't match expected type `[t]' with actual type `[a0] -> [a0]' Relevant bindings include l :: [t] (bound at PP-06-haskell-intro-s.hs:32:6) len1 :: [t] -> [t] -> t1 (bound at PP-06-haskell-intro-s.hs:32:1) Probable cause: `tail' is applied to too few arguments In the first argument of `len1', namely `tail' In the second argument of `(+)', namely `len1 tail l' Failed, modules loaded: none. λ> λ> maxList [5, 3, 2, 8, 1, 10, 4] 10 λ> :r Ok, modules loaded: Main. λ> :t maxList maxList :: Ord t => [t] -> t λ> maxList [] *** Exception: PP-06-haskell-intro-s.hs:(76,1)-(77,33): Non-exhaustive patterns in function maxList λ> λ> maxList [5, 3, 2, 8, 1, 10, 4] 10 λ> maxList [4] 4 λ> maxList [] *** Exception: Prelude.undefined λ> λ> λ> λ> λ> λ> λ> :t map map :: (a -> b) -> [a] -> [b] λ> :t filter filter :: (a -> Bool) -> [a] -> [a] λ> :t foldl foldl :: (b -> a -> b) -> b -> [a] -> b λ> :t foldr foldr :: (a -> b -> b) -> b -> [a] -> b λ> [x | x <- [1..], x < 20, even x] [2,4,6,8,10,12,14,16,18Interrupted. λ> [x | x <- [1..20], even x] [2,4,6,8,10,12,14,16,18,20] λ> [x*x | x <- [1..20], even x] [4,16,36,64,100,144,196,256,324,400] λ> [(x*x, even x) | x <- [1..10]] [(1,False),(4,True),(9,False),(16,True),(25,False),(36,True),(49,False),(64,True),(81,False),(100,True)] λ> λ> [(x, y) | x <- [1..10], y <- [1..10], x + y == 10] [(1,9),(2,8),(3,7),(4,6),(5,5),(6,4),(7,3),(8,2),(9,1)] λ> [(x, y) | x <- [1..10], y <- [1..x], x + y == 10] [(5,5),(6,4),(7,3),(8,2),(9,1)] λ> [(x, y) | x <- [1..10], even x, y <- [1..x], x + y == 10] [(6,4),(8,2)] λ> [(x, y) | even x, x <- [1..10], y <- [1..x], x + y == 10] [] λ> λ> ones [1,1,1 ...] λ> take 10 ones [1,1,1,1,1,1,1,1,1,1] λ> λ> take 20 naturals [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19] λ> zipWith (+) [1..10] [5..20] [6,8,10,12,14,16,18,20,22,24] λ> zipWith (,) ['a'..'z'] [1..20] [('a',1),('b',2),('c',3),('d',4),('e',5),('f',6),('g',7),('h',8),('i',9),('j',10),('k',11),('l',12),('m',13),('n',14),('o',15),('p',16),('q',17),('r',18),('s',19),('t',20)] λ> :t (,) (,) :: a -> b -> (a, b) λ> :r [1 of 1] Compiling Main ( PP-06-haskell-intro-s.hs, interpreted ) Ok, modules loaded: Main. λ> take 20 naturals2 [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19] λ> take 20 $ zipWith (+) naturals naturals [0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38]