Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions backend/junior-3/haskell.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* [Introduction to Tagless Final](https://serokell.io/blog/2018/12/07/tagless-final)


## TypeOperators and type classes extensions:
## TypeOperators and type classes extensions

* `TypeOperators`
* `FlexibleContexts` & `FlexibleInstances`
Expand Down Expand Up @@ -127,7 +127,7 @@
* `ScopedTypeVariables`
* What is the main goal of this extension?
* Higher ranked types
* What is a "rank" of a function?
* What is a higher rank function?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вопрос "как определяется ранг функции", на мой взгляд - вполне корректный и не нуждается в удалении. Можно пояснить, почему он заменяется на "что такое функция высшего ранга"? Это более слабый вопрос, поскольку в нём не уточняется, например, чем именно отличается функция 2-го ранга от функции 3-го.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Чтобы определять числовой ранг функции, у нас не хватает источника. В доках по хаскелю не объяснено, как по сигнатуре определить ранг.

Стас говорил, что определение ранга непростое, и мы подумали, что оно на практике не нужно. Достаточно отличать первый ранг от всех остальных, а уж какой он - третий или четвертый - не влияет на то, как применять RankNTypes.

* Give examples of rank-1, rank-2, rank-3 functions.
* What is the main goal of `RankNTypes` extension?
* Can we create datatypes and newtypes with `RankNTypes`?
Expand Down Expand Up @@ -197,18 +197,24 @@
* `1:(thunk)`
* `1:2:(thunk)`
* `1:2:3:[]`
* `thunk:thunk`
* `15`
* `\x -> x * 2`
* `(\x -> x + 1) 3`
* Can haskell evaluate in strict mode?
* Why strict functions in Haskell evaluate values to WHNF and not NF?
* Why are values in Haskell typically (when using `Strict`, `seq`, `foldl'`,
`modifyIORef'` etc) calculated to WHNF, not to NF?
* What is the function `seq` (and operator `$!`)?
* What is the function `deepseq` (and operator `$!!`)?
* Could using `seq` change the returned value of the function?
* In which way does runtime behavior of the following expressions differ?
* ``a + b `seq` (a + b) : list``
* ``let s = a + b in s `seq` s : list``
* What are conditions when `seq` or `deepseq` can actually evaluate a value?
* What is the GHC extension `BangPatterns`?
* Make examples when bang pattern is useless.
* Make examples when bang pattern has less power, than it could be supposed.
* Show the difference between this two definitions:
* Make examples when a bang pattern is useless.
* Do bang patterns force values to WHNF or NF?
* Show the difference between these two definitions:
* `f1`

```haskell
Expand All @@ -223,11 +229,13 @@
f2 x False = False
```

* Does bang patterns force execution, when they are nested in constructors inside of `let` or `where` expressions?
* There is a `!` inside a `Maybe`, which is inside a `let` expression, and `let` expressions are lazy:
* Do bang patterns force execution when they are nested in constructors inside
`let` or `where` expressions? Does this force `a` to be evaluated or when
it does?

```haskell
let (Just !a) = x in 1 + 1
let (Just !a) = x in [a]
```

* What are the GHC extensions `Strict` and `StrictData`?
Expand Down Expand Up @@ -260,6 +268,8 @@
* [Brief normal forms explanation with Haskell - Medium article](https://medium.com/@aleksandrasays/brief-normal-forms-explanation-with-haskell-cd5dfa94a157)
* [All About Strictness. - FP Complete](https://www.fpcomplete.com/blog/2017/09/all-about-strictness)
* [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)
* See "Learning to use `seq`",
[Real World Haskell](http://book.realworldhaskell.org/read/functional-programming.html) book.

## Lists

Expand Down