|
44 | 44 | * [Introduction to Tagless Final](https://serokell.io/blog/2018/12/07/tagless-final) |
45 | 45 |
|
46 | 46 |
|
47 | | -## TypeOperators and type classes extensions: |
| 47 | +## TypeOperators and type classes extensions |
48 | 48 |
|
49 | 49 | * `TypeOperators` |
50 | 50 | * `FlexibleContexts` & `FlexibleInstances` |
|
127 | 127 | * `ScopedTypeVariables` |
128 | 128 | * What is the main goal of this extension? |
129 | 129 | * Higher ranked types |
130 | | - * What is a "rank" of a function? |
| 130 | + * What is a higher rank function? |
131 | 131 | * Give examples of rank-1, rank-2, rank-3 functions. |
132 | 132 | * What is the main goal of `RankNTypes` extension? |
133 | 133 | * Can we create datatypes and newtypes with `RankNTypes`? |
|
197 | 197 | * `1:(thunk)` |
198 | 198 | * `1:2:(thunk)` |
199 | 199 | * `1:2:3:[]` |
| 200 | + * `thunk:thunk` |
200 | 201 | * `15` |
201 | 202 | * `\x -> x * 2` |
202 | 203 | * `(\x -> x + 1) 3` |
203 | 204 | * Can haskell evaluate in strict mode? |
204 | | -* Why strict functions in Haskell evaluate values to WHNF and not NF? |
| 205 | +* Why are values in Haskell typically (when using `Strict`, `seq`, `foldl'`, |
| 206 | + `modifyIORef'` etc) calculated to WHNF, not to NF? |
205 | 207 | * What is the function `seq` (and operator `$!`)? |
206 | 208 | * What is the function `deepseq` (and operator `$!!`)? |
207 | 209 | * Could using `seq` change the returned value of the function? |
| 210 | +* In which way does runtime behavior of the following expressions differ? |
| 211 | + * ``a + b `seq` (a + b) : list`` |
| 212 | + * ``let s = a + b in s `seq` s : list`` |
| 213 | +* What are conditions when `seq` or `deepseq` can actually evaluate a value? |
208 | 214 | * What is the GHC extension `BangPatterns`? |
209 | | - * Make examples when bang pattern is useless. |
210 | | - * Make examples when bang pattern has less power, than it could be supposed. |
211 | | - * Show the difference between this two definitions: |
| 215 | + * Make examples when a bang pattern is useless. |
| 216 | + * Do bang patterns force values to WHNF or NF? |
| 217 | + * Show the difference between these two definitions: |
212 | 218 | * `f1` |
213 | 219 |
|
214 | 220 | ```haskell |
|
223 | 229 | f2 x False = False |
224 | 230 | ``` |
225 | 231 |
|
226 | | - * Does bang patterns force execution, when they are nested in constructors inside of `let` or `where` expressions? |
227 | | - * There is a `!` inside a `Maybe`, which is inside a `let` expression, and `let` expressions are lazy: |
| 232 | + * Do bang patterns force execution when they are nested in constructors inside |
| 233 | + `let` or `where` expressions? Does this force `a` to be evaluated or when |
| 234 | + it does? |
228 | 235 |
|
229 | 236 | ```haskell |
230 | 237 | let (Just !a) = x in 1 + 1 |
| 238 | + let (Just !a) = x in [a] |
231 | 239 | ``` |
232 | 240 |
|
233 | 241 | * What are the GHC extensions `Strict` and `StrictData`? |
|
260 | 268 | * [Brief normal forms explanation with Haskell - Medium article](https://medium.com/@aleksandrasays/brief-normal-forms-explanation-with-haskell-cd5dfa94a157) |
261 | 269 | * [All About Strictness. - FP Complete](https://www.fpcomplete.com/blog/2017/09/all-about-strictness) |
262 | 270 | * [Does a function in Haskell always evaluate its return value? - Stackoverflow](https://stackoverflow.com/questions/27685224/does-a-function-in-haskell-always-evaluate-its-return-value) |
| 271 | + * See "Learning to use `seq`", |
| 272 | + [Real World Haskell](http://book.realworldhaskell.org/read/functional-programming.html) book. |
263 | 273 |
|
264 | 274 | ## Lists |
265 | 275 |
|
|
0 commit comments