Skip to content
Merged
Show file tree
Hide file tree
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
223 changes: 125 additions & 98 deletions backend/junior-3/haskell.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
* Monads
* Антон Холомьёв. Учебник по Haskell. Глава 8. IO

### Types

* What is kind?

### Lists

* What is the difference between `foldl'`, `foldr'` and `foldl`, `foldr`?
Expand Down Expand Up @@ -75,7 +71,8 @@
* Final tagless
* [Introduction to Tagless Final](https://serokell.io/blog/2018/12/07/tagless-final)

### GHC extensions

### Deriving, RecordWildCards, TypeOperators, type classes' extensions

* Extensions for deriving:
* `StandaloneDeriving`
Expand All @@ -84,117 +81,147 @@
* `DeriveTraversable`
* `GeneralizedNewtypeDeriving`
* `DeriveAnyClass`
* `DerivingVia`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Для DerivingVia нужно знать Coercible, representations и, возможно, даже type roles. Может, добавить и Coercible, либо убрать DerivingVia. Не надо стремиться запихнуть все дерайвинги в одно место только потому, что это дерайвинги ).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Создал связанный ишью #298 . Но я думаю что тут не нужно подробно знать что такое Coercible для того чтобы понять зачем нужен DerivingVia, поэтому в ишью написал два предложения, одно из базовых вопросов, другое для получения углубленных знаний по теме.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Тогда оставляем.

* `DerivingStrategies`
* `RecordWildCards`
* `TypeOperators`
* `FlexibleContexts` & `FlexibleInstances`
* `MultiParamTypeClasses` & `FunctionalDependencies`
* Type and Data Families
* What are the three variations of type families: closed, open, associated?
What are their difference and purpose?
* What is injectivity?
* Is open type/data family injective?
Would type/data family be injective if it was associated with a type class?
Would type/data family be injective if it would be closed?
* Why there are no closed data families?
* Can open type family instances overlap with parameters? Can closed typed families do it?
* How closed type families can help to create overlapping type classes instances?
* What are the differences between Functional Dependencies and associated Type Families?
What are the situations when the best choice would be to use associated type families, and when it would be fundeps?
* GADTs
* What is the difference between GADT and ADT?
* What is the main goal of GADT?
* What is the difference between `GADTs` and phantom types?
* How GADT helps us to go from type level to term level in pattern matching?
* Are record fields available for GADT?
* Is it considered a good practice to put constraints in consructors inside GADT declaration?
* How does deriving instances work for GADT? What problems may occur?
* Data Kinds
* What is the kind `*`? What is the kind `Type`?
* What is the data type promotion?
* What is the main goal for using `DataKinds`?
* Is apostrophe (' symbol) required in a name of a promoted data type?
* Are types with promoted kinds inhabited?
* What is inconvenience we've got with `DataKinds`, concerned with terms level of promoted types?
* What are types which can't be promoted?
* How can heterogenous lists be implemented with `DataKinds` and `GADTs`?
* What are the dependent types and how `DataKinds` allow us to get closer to them?
* Polymorphic Kinds
* What is the main goal of `PolyKinds`?
* How it can be used?
* What declarations would have the inferred kind `*` and not polykinded `forall k. k`?
* What is `Proxy` datatype? What is it used for? Why do we need `PolyKinds` to implement it?

##### Resources

* RecordWildCards

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Одинокий элемент списка, может его выпилить и поднять дочерние элементы на уровень вверх? В других местах аналогично:

  • источники по тайпфемили
  • источники по Higher ranked types (только к источнику GHC Docs надо бы дописать, что это дока именно по HRT, а то в этом разделе спрашивается еще про scoped type variables).

@olegromashin olegromashin Mar 23, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Тайп фемелис поправил. У остальных сделано также как и везде: в пачке, которая сдаётся вместе и имеет один подраздел ресурсов, указывается к какой теме относится источник так как сейчас.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

В названии ресурса по wildcards уже есть слово wildcards - не перепутаешь. Я бы оставил двухуровневый список только в том случае, если есть хотя бы два ресурса по wildcards и хотя бы один ресурс по другой теме - тогда получилась бы наглядная группировка. А сейчас это часть структуры документа, которая ничего не структурирует, не улучшает навигацию. Но я не настаиваю.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ну меня вообще тоже любой вариант устроит. Я просто с расчётом на то, что что-то добавиться может и структуру не поменяют в итоге.

* [The Power of RecordWildCards](https://kodimensional.dev/recordwildcards)

### Type and Data Families

* What are the three variations of type families: closed, open, associated? What are their difference and purpose?
* What is injectivity?
* Is open type/data family injective? Would type/data family be injective if it was associated with a type class? Would type/data family be injective if it would be closed?
* Why there are no closed data families?
* Can open type family instances overlap with parameters? Can closed typed families do it?
* How closed type families can help to create overlapping type classes instances?
* What are the differences between Functional Dependencies and associated Type Families? What are the situations when the best choice would be to use associated type families, and when it would be fundeps?

##### Resources

* [Haskell's Type Families presentation](https://cdepillabout.github.io/haskell-type-families-presentation/#/)
* [24 Days of GHC Extensions: Type Families](https://ocharles.org.uk/blog/posts/2014-12-12-type-families.html)
* [Haskell Injectivity Of Type Families And Reasons Of Its Ambiguity](https://wapxmas.github.io/haskell-injectivity/)
* [Avoid overlapping instances with closed type families](https://kseo.github.io/posts/2017-02-05-avoid-overlapping-instances-with-closed-type-families.html)
* [String interpolation and overlapping instances 101](https://williamyaoh.com/posts/2019-05-27-string-interpolation-and-overlapping-instances.html)
* [Type families usage in servant](https://arow.info/blog/posts/2015-07-10-servant-intro.html)
* [Why can't we define closed data families?](https://stackoverflow.com/questions/49433716/why-cant-we-define-closed-data-families)

### GADTs

* What is the difference between GADT and ADT?
* What is the main goal of GADT?
* What is the difference between `GADTs` and phantom types?
* How GADT helps us to go from type level to term level in pattern matching?
* Are record fields available for GADT?
* Is it considered a good practice to put constraints in consructors inside GADT declaration?
* How does deriving instances work for GADT? What problems may occur?

##### Resources

* [Wikibooks](<https://en.wikibooks.org/wiki/Haskell/GADT>)
* [Haskell wiki](<https://wiki.haskell.org/GADTs_for_dummies>)
* [GHC docs](https://downloads.haskell.org/~ghc/8.8-latest/docs/html/users_guide/glasgow_exts.html#extension-GADTs)
* [Fun with phantom types](http://www.cs.ox.ac.uk/ralf.hinze/publications/With.pdf)
* [Type Constraints in Data Declaration Haskell](https://stackoverflow.com/questions/40825878/type-constraints-in-data-declaration-haskell)
* [GADTs vs. MultiParamTypeClasses](https://stackoverflow.com/questions/10994508/gadts-vs-multiparamtypeclasses)

### DataKinds

* What is kind?
* What is the kind `*`? What is the kind `Type`?
* What is the data type promotion?
* What is the main goal for using `DataKinds`?
* Is apostrophe (' symbol) required in a name of a promoted data type?
* Are types with promoted kinds inhabited?
* Can we create a function from a regular data type into promoted one and vice versa?
* What are types which can't be promoted?
* How can heterogenous lists be implemented with `DataKinds` and `GADTs`?
* What are the dependent types and how `DataKinds` allow us to get closer to them?

##### Resources

* [GHC docs](https://downloads.haskell.org/~ghc/8.8-latest/docs/html/users_guide/glasgow_exts.html#extension-DataKinds)
* [Paper - Giving Haskell a Promotion](https://www.seas.upenn.edu/~sweirich/papers/tldi12.pdf)
* [Basic Type Level Programming in Haskell](http://www.parsonsmatt.org/2017/04/26/basic_type_level_programming_in_haskell.html)
* [Haskell's kind system - a primer](https://diogocastro.com/blog/2018/10/17/haskells-kind-system-a-primer/)
* [The Future of Programming is Dependent Types — Programming Word of the Day](https://medium.com/background-thread/the-future-of-programming-is-dependent-types-programming-word-of-the-day-fcd5f2634878)
* [What is dependent typing?](https://stackoverflow.com/questions/9338709/what-is-dependent-typing)
* [Does haskell have dependent types?](https://softwareengineering.stackexchange.com/questions/182066/does-haskell-have-dependent-types)

### Polymorphic Kinds

* What is the main goal of `PolyKinds`?
* How it can be used?
* What declarations would have the inferred kind `*` and not polykinded `forall k. k`?
* What is `Proxy` datatype? What is it used for? Why do we need `PolyKinds` to implement it?

##### Resources

* [GHC docs](https://downloads.haskell.org/~ghc/8.8-latest/docs/html/users_guide/glasgow_exts.html#kind-polymorphism-and-type-in-type)
* [Kwang's Haskell Blog - Data.Proxy](https://kseo.github.io/posts/2017-01-15-data-proxy.html)

### ScopedTypeVariables, Higher ranked types

* `ScopedTypeVariables`
* What is the main goal of this extension?
* Higher ranked types
* What is a "rank" of a function?
* Give examples of rank-1, rank-2, rank-3 functions.
* What is the main goal of `RankNTypes` extension?
* Provide example cases on when we can use `ExistentialQuantification` and when we can use `RankNTypes`.
Comment thread
olegromashin marked this conversation as resolved.
* Can we create datatypes and newtypes with `RankNTypes`?
* Can we use constraints with `RankNTypes`?
* `ExistentialQuantification`
* What is the main goal of the `ExistentialQuantification` extension?
* Can we use constraints for types of quantified constructor parameters?
* Can we use different constraints for different constructor?
* Could we use existentially quantified types in record constructors?
* What is the scope of existential type variables?
* Can we use `ExistentialQuantification` when declaring `newtype`?
* Can we pattern-match on an existentially quantified constructor in `let` or `where` block?
* Can we pattern-match on an existentially quantified constructor in `case` block?
* Can we use `deriving` with existentially quantified data types?
* Why is there no `exist` keyword in Haskell?
* What are the situations which require using `ScopedTypeVariables`, `ExistentialQuantification`, `RankNTypes`?
Compare the use cases of theese extensions.
* Could existential type be promoted with `DataKinds` extension?
* `ConstraintKinds`
* What is the main goal of the extension?
* What types and type variables would have a kind `Constraint` with this extension enabled?
* What is the pattern of Indexed constraints? What is its goal?
* How pattern Reified dictionaries can be implemented with this extension enabled?
* How Generic programming can be improved with this extension enabled?
* Could classes be partially applied?

#### GHC extensions resources

* RecordWildCards
* [The Power of RecordWildCards](https://kodimensional.dev/recordwildcards)
* Type and Data Families
* [Avoid overlapping instances with closed type families](https://kseo.github.io/posts/2017-02-05-avoid-overlapping-instances-with-closed-type-families.html)
* [String interpolation and overlapping instances 101](https://williamyaoh.com/posts/2019-05-27-string-interpolation-and-overlapping-instances.html)
* [Type families usage in servant](https://arow.info/blog/posts/2015-07-10-servant-intro.html)
* GADTs
* [Wikibooks](<https://en.wikibooks.org/wiki/Haskell/GADT>)
* [Haskell wiki](<https://wiki.haskell.org/GADTs_for_dummies>)
* [GHC docs](https://downloads.haskell.org/~ghc/8.8-latest/docs/html/users_guide/glasgow_exts.html#extension-GADTs)
* [Fun with phantom types](http://www.cs.ox.ac.uk/ralf.hinze/publications/With.pdf)
* [Type Constraints in Data Declaration Haskell](https://stackoverflow.com/questions/40825878/type-constraints-in-data-declaration-haskell)
* DataKinds
* [GHC docs](https://downloads.haskell.org/~ghc/8.8-latest/docs/html/users_guide/glasgow_exts.html#extension-DataKinds)
* [Paper - Giving Haskell a Promotion](https://www.seas.upenn.edu/~sweirich/papers/tldi12.pdf)
* [Basic Type Level Programming in Haskell](http://www.parsonsmatt.org/2017/04/26/basic_type_level_programming_in_haskell.html)
* [Haskell's kind system - a primer](https://diogocastro.com/blog/2018/10/17/haskells-kind-system-a-primer/)
* [The Future of Programming is Dependent Types — Programming Word of the Day](https://medium.com/background-thread/the-future-of-programming-is-dependent-types-programming-word-of-the-day-fcd5f2634878)
* [What is dependent typing?](https://stackoverflow.com/questions/9338709/what-is-dependent-typing)
* [Does haskell have dependent types?](https://softwareengineering.stackexchange.com/questions/182066/does-haskell-have-dependent-types)
* PolyKinds
* [GHC docs](https://downloads.haskell.org/~ghc/8.8-latest/docs/html/users_guide/glasgow_exts.html#kind-polymorphism-and-type-in-type)
##### Resources

* Higher ranked types
* [GHC docs](https://downloads.haskell.org/~ghc/8.8-latest/docs/html/users_guide/glasgow_exts.html#extension-RankNTypes)
* [Higher-rank and higher-kinded types](https://www.stephanboyer.com/post/115/higher-rank-and-higher-kinded-types)
* [Haskell wiki](https://wiki.haskell.org/Rank-N_types)
* Existential types
* [Haskell Wiki](https://wiki.haskell.org/Existential_type)
* [GHC docs](https://downloads.haskell.org/~ghc/8.8-latest/docs/html/users_guide/glasgow_exts.html#existentially-quantified-data-constructors)
* [WikiBooks](https://en.wikibooks.org/wiki/Haskell/Existentially_quantified_types)
* [Why there is no an "Exist" keyword](https://stackoverflow.com/questions/28545545/why-there-is-no-an-exist-keyword-in-haskell-for-existential-quantification)
* [What's the theoretical basis for existential types](https://stackoverflow.com/questions/10753073/whats-the-theoretical-basis-for-existential-types)
* [What does the `forall` keyword in Haskell/GHC do](https://stackoverflow.com/questions/3071136/what-does-the-forall-keyword-in-haskell-ghc-do)
* [Logic for Economists (optional resource)](https://www.coursera.org/learn/logic-for-economists/home/welcome)
* `ConstraintKinds`
* [GHC docs](https://downloads.haskell.org/~ghc/8.8-latest/docs/html/users_guide/glasgow_exts.html#extension-ConstraintKinds)
* [Constraint Kinds for GHC](http://blog.omega-prime.co.uk/2011/09/10/constraint-kinds-for-ghc/)
* [The Constraint kind](https://jeltsch.wordpress.com/2013/02/14/the-constraint-kind/)

### ExistentialQuantification

* What is the main goal of the `ExistentialQuantification` extension?
* Can we use constraints for types of quantified constructor parameters?
* Can we use different constraints for different constructor?
* Could we use existentially quantified types in record constructors?
* What is the scope of existential type variables?
* Can we use `ExistentialQuantification` when declaring `newtype`?
* Can we pattern-match on an existentially quantified constructor in `let` or `where` block?
* Can we pattern-match on an existentially quantified constructor in `case` block?
* Can we use `deriving` with existentially quantified data types?
* Why is there no `exist` keyword in Haskell?
* What are the situations which require using `ScopedTypeVariables`, `ExistentialQuantification`, `RankNTypes`? Compare the use cases of these extensions.
* Could existential type be promoted with `DataKinds` extension?

##### Resources

* [Haskell Wiki](https://wiki.haskell.org/Existential_type)
* [GHC docs](https://downloads.haskell.org/~ghc/8.8-latest/docs/html/users_guide/glasgow_exts.html#existentially-quantified-data-constructors)
* [WikiBooks](https://en.wikibooks.org/wiki/Haskell/Existentially_quantified_types)
* [Why there is no an "Exist" keyword](https://stackoverflow.com/questions/28545545/why-there-is-no-an-exist-keyword-in-haskell-for-existential-quantification)
* [What's the theoretical basis for existential types](https://stackoverflow.com/questions/10753073/whats-the-theoretical-basis-for-existential-types)
* [What does the `forall` keyword in Haskell/GHC do](https://stackoverflow.com/questions/3071136/what-does-the-forall-keyword-in-haskell-ghc-do)

### ConstraintKinds

* What is the main goal of the extension?
* What types and type variables would have a kind `Constraint` with this extension enabled?
* What is the pattern of Indexed constraints? What is its goal?
* How pattern Reified dictionaries can be implemented with this extension enabled?
* Could classes be partially applied?

##### Resources

* [GHC docs](https://downloads.haskell.org/~ghc/8.8-latest/docs/html/users_guide/glasgow_exts.html#extension-ConstraintKinds)
* [Constraint Kinds for GHC](http://blog.omega-prime.co.uk/2011/09/10/constraint-kinds-for-ghc/)
* [The Constraint kind](https://jeltsch.wordpress.com/2013/02/14/the-constraint-kind/)

### Laziness

Expand Down
2 changes: 2 additions & 0 deletions backend/middle-1/haskell.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,15 @@ Why is `unliftio` considered safer by the author of `safe-exceptions`?
* Suppose we have `data Example b c = A | B b | C Int c`:
* What is the `Rep (Example b c)` type?
* What would be the result of `to (C 2 "fsd")`?
* How Generic programming can be improved with `ConstraintKinds` extension enabled?

#### Generics resources
Comment thread
olegromashin marked this conversation as resolved.

* [What is datatype-generic programming](https://maxhallinan.com/posts/2019/09/17/what-is-datatype-generic-programming/)
* [GHC.Generics on Wiki Haskell](https://wiki.haskell.org/GHC.Generics)
* [GHC Generics Explained](https://www.stackbuilders.com/tutorials/haskell/generics/)
* [Haddock (functions for getting information about datatypes)](https://hackage.haskell.org/package/base-4.8.2.0/docs/GHC-Generics.html#t:Datatype)
* [Constraint Kinds for GHC](http://blog.omega-prime.co.uk/2011/09/10/constraint-kinds-for-ghc/)

### Lenses

Expand Down