Skip to content

Commit 1e13742

Browse files
authored
Merge pull request #341 from fullstack-development/jun3-haskell-fixes
jun3/haskell: fix questions and add some new
2 parents 4704237 + 22766f5 commit 1e13742

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

backend/junior-3/haskell.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
* [Introduction to Tagless Final](https://serokell.io/blog/2018/12/07/tagless-final)
4545

4646

47-
## TypeOperators and type classes extensions:
47+
## TypeOperators and type classes extensions
4848

4949
* `TypeOperators`
5050
* `FlexibleContexts` & `FlexibleInstances`
@@ -127,7 +127,7 @@
127127
* `ScopedTypeVariables`
128128
* What is the main goal of this extension?
129129
* Higher ranked types
130-
* What is a "rank" of a function?
130+
* What is a higher rank function?
131131
* Give examples of rank-1, rank-2, rank-3 functions.
132132
* What is the main goal of `RankNTypes` extension?
133133
* Can we create datatypes and newtypes with `RankNTypes`?
@@ -197,18 +197,24 @@
197197
* `1:(thunk)`
198198
* `1:2:(thunk)`
199199
* `1:2:3:[]`
200+
* `thunk:thunk`
200201
* `15`
201202
* `\x -> x * 2`
202203
* `(\x -> x + 1) 3`
203204
* 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?
205207
* What is the function `seq` (and operator `$!`)?
206208
* What is the function `deepseq` (and operator `$!!`)?
207209
* 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?
208214
* 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:
212218
* `f1`
213219

214220
```haskell
@@ -223,11 +229,13 @@
223229
f2 x False = False
224230
```
225231

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?
228235

229236
```haskell
230237
let (Just !a) = x in 1 + 1
238+
let (Just !a) = x in [a]
231239
```
232240

233241
* What are the GHC extensions `Strict` and `StrictData`?
@@ -260,6 +268,8 @@
260268
* [Brief normal forms explanation with Haskell - Medium article](https://medium.com/@aleksandrasays/brief-normal-forms-explanation-with-haskell-cd5dfa94a157)
261269
* [All About Strictness. - FP Complete](https://www.fpcomplete.com/blog/2017/09/all-about-strictness)
262270
* [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.
263273

264274
## Lists
265275

0 commit comments

Comments
 (0)