``-- Basics-- The -- is used for comments2 + 3 * 4 -- 14(2 + 3) * 4 -- 20-- Alternative notation(+) 2 ((*) 3 4) -- 14(*) ((+) 2 3) 4 -- 20-- sqrt is a standard library functionsqrt (3^2 + 4^2) -- 5.0-- Anything in [] is a list which-- differs from an array or a vectorhead [1,2,3,4,5] -- 1tail [1,2,3,4,5] -- [2,3,4,5]-- Index from list at linear time[1,2,3,4,5] !! 2 -- 3take 3 [1,2,3,4,5] -- [1,2,3]drop 3 [1,2,3,4,5] -- [4,5]length [1,2,3,4,5] -- 5sum [1,2,3,4,5] -- 15product [1,2,3,4,5] -- 120reverse [1,2,3,4,5] -- [5,4,3,2,1][1,2,3] ++ [4,5] -- [1,2,3,4,5]-- Character-- '' are used for single character'H' -- Char-- String-- "" are used for a string"Hi" -- [Char]"Hel" ++ "lo" -- "Hello"length "Hello" -- 5-- BooleanTrue -- TrueFalse -- FalseTrue || False -- Truenot True && False -- False-- Functionsdouble x = x + x -- Num a => a -> adouble 2 -- 4quadruple x = double (double x) -- Num a => a -> aquadruple 2 -- 8factorial n = product [1..n] -- (Num a, Enum a) => a -> afactorial 5 -- 120-- f x y is equal to x `f` y-- `ns` indicates a list which is simplified Hungarian notationaverage ns = sum ns `div` length ns -- Foldable t => t Int -> Intaverage [1,2,3,4,5] -- 3-- Types:t 1 -- 1 :: Num p => p:t True -- True :: Bool:t 'H' -- 'H' :: Char:t "Hello" -- "Hello" :: [Char]:t head "Hello" -- head "Hello" :: Char:t length -- length :: Foldable t => t a -> Int-- Tuples(1, 2) -- (Num a, Num b) => (a, b)(1, "Hello") -- Num a => (a, [Char])(1, (2, 3)) -- (Num a1, Num a2, Num b) => (a1, (a2, b))fst (1, "Hello") -- 1snd (1, "Hello") -- "Hello":t fst -- (a, b) -> a:t snd -- (a, b) -> bfst (snd (1, (2, 3))) -- 2-- That's all folks!``