3Haskell is a functional language based on typed lambda calculus where
4everything is a well-typed expression, meaning it would allow you to do the
8apply :: (Int -> Int) -> Int
12In most other languages, trying to evaluate this function on any argument would
13lead to stack overflow. However, the following safely terminates in Haskell
17value = apply (\_ -> 5)
18-- apply (\_ -> 5) = (\_ -> 5) (apply (\_ -> 5)) = 5
21This is possible thanks to the special runtime system of Haskell, or RTS for
22short. It computes values lazily rather than eagerly; this means that
27foldr :: (a -> b -> b) -> b -> [a] -> b
29foldr f b (x : xs) = f x (foldr f b xs)
30-- foldr (:) [] [1..1000] = 1 : foldr (:) [] [2..1000] =
31-- 1 : 2 : foldr (:) [] [3..1000]
33foldl :: (b -> a -> b) -> b -> [a] -> b
35foldl f b (x : xs) = foldl f (f b x) xs
36-- foldl (;) [] [1..1000] = foldl (;) (1 : []) [2..1000]
37-- = foldl (;) (2 : 1 : []) [3..1000] = ...
41foldl' :: (b -> a -> b) -> b -> [a] -> b
45 in b' `seq` foldl' f b' xs
49foldl'' :: (b -> a -> b) -> b -> [a] -> b
51foldl'' f !b (x : xs) = foldl'' f (f b x) xs
54Strict fields in records
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list