From 66f1571a937c7f75d7b83be098143ccb4d2d16da Mon Sep 17 00:00:00 2001 From: krashaen Date: Wed, 3 Nov 2021 08:55:31 +0700 Subject: [PATCH 1/3] change jun3 haskell for parser --- backend/junior-3/haskell.md | 119 ++++++++++++++++++------------------ 1 file changed, 60 insertions(+), 59 deletions(-) diff --git a/backend/junior-3/haskell.md b/backend/junior-3/haskell.md index 52d1d2c4..9b087b13 100644 --- a/backend/junior-3/haskell.md +++ b/backend/junior-3/haskell.md @@ -99,29 +99,6 @@ * [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) - ## ScopedTypeVariables, Higher ranked types * `ScopedTypeVariables` @@ -140,41 +117,6 @@ * [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) -## 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) - -## Extensions Practice - -* Solve kata. - * [Count them all!](https://www.codewars.com/kata/5b1bdc2bccef79e948000086) - * [Singletons](https://www.codewars.com/kata/54750ed320c64c64e20002e2) -* Write your own tiny implementation of servant. - For reference use this [guide](https://www.well-typed.com/blog/2015/11/implementing-a-minimal-version-of-haskell-servant/). -* Solve practice exercises. You may ask your interviewers if you have difficulties. - * [Test understanding of functional dependencies](../../backend/junior-3/Practice/FunctionalDependencies.hs) - * [Test understanding of DataKinds used with TypeFamilies and FunctionalDependencies](../../backend/junior-3/Practice/DataKinds.hs) - * [Test understanding of ExistentialQuantification and RankNTypes](../../backend/junior-3/Practice/ExistentialQuantification.hs) ## Laziness @@ -301,7 +243,66 @@ Should we ban using this pattern? * [Exceptions tutorial from IH book](https://markkarpov.com/tutorial/exceptions.html) Quite hard to read for this level, you would better reread it later. -## Debugging +## [Optional] 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) + +## [Optional] 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) + +## [Optional] Extensions Practice + +* Solve kata. + * [Count them all!](https://www.codewars.com/kata/5b1bdc2bccef79e948000086) + * [Singletons](https://www.codewars.com/kata/54750ed320c64c64e20002e2) +* Write your own tiny implementation of servant. + For reference use this [guide](https://www.well-typed.com/blog/2015/11/implementing-a-minimal-version-of-haskell-servant/). +* Solve practice exercises. You may ask your interviewers if you have difficulties. + * [Test understanding of functional dependencies](../../backend/junior-3/Practice/FunctionalDependencies.hs) + * [Test understanding of DataKinds used with TypeFamilies and FunctionalDependencies](../../backend/junior-3/Practice/DataKinds.hs) + * [Test understanding of ExistentialQuantification and RankNTypes](../../backend/junior-3/Practice/ExistentialQuantification.hs) + +## [Optional] Debugging * `Debug.Trace` * How is it useful? From 943356bde12b3692b0b79f6c30bdf4710b8a9465 Mon Sep 17 00:00:00 2001 From: olgaklimenko Date: Wed, 9 Feb 2022 21:36:07 +0700 Subject: [PATCH 2/3] add formatting example script for 1 file --- backend/junior-3/haskell.md | 26 +++++++++++++------------- format.sh | 8 ++++++++ 2 files changed, 21 insertions(+), 13 deletions(-) create mode 100644 format.sh diff --git a/backend/junior-3/haskell.md b/backend/junior-3/haskell.md index 9b087b13..cb3d9199 100644 --- a/backend/junior-3/haskell.md +++ b/backend/junior-3/haskell.md @@ -1,6 +1,6 @@ # Haskell for Junior-3 -## Type classes +## Type classes * Why using constraints on a type variable within a data declaration isn't a good idea? * What is coherence and why is it important to maintain it? What are the possible cases of coherence violation? @@ -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` @@ -60,7 +60,7 @@ * [FPComplete: Functional Dependencies](https://www.fpcomplete.com/haskell/tutorial/fundeps/) -## Type and Data Families +## Type and Data Families * What are the three variations of type families: closed, open, associated? What are their difference and purpose? * What is injectivity? @@ -80,7 +80,7 @@ * [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 +## GADTs * What is the difference between GADT and ADT? * What is the main goal of GADT? @@ -99,7 +99,7 @@ * [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) -## ScopedTypeVariables, Higher ranked types +## ScopedTypeVariables, Higher ranked types * `ScopedTypeVariables` * What is the main goal of this extension? @@ -118,7 +118,7 @@ * [Haskell wiki](https://wiki.haskell.org/Rank-N_types) -## Laziness +## Laziness * What is a reduction strategy? What is an evaluation strategy? How do they differ? * What is lazy evaluation? How it differs from eager evaluation? Is lazy evaluation the same as non-strictness? @@ -203,7 +203,7 @@ * [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) -## Lists +## Lists * What is the difference between `foldl'`, `foldr'` and `foldl`, `foldr`? * How `foldl`, `foldl'`, `foldr` and `foldr'` behave with infinite lists, and why do they have the particular behavior? @@ -214,7 +214,7 @@ * [Fixing `foldl`](http://www.well-typed.com/blog/90/) -## Exceptions +## Exceptions * What is the exception free pattern? * How do we abstract the possibility of failure in Haskell? @@ -235,7 +235,7 @@ Should we ban using this pattern? * Why do we need the exception hierarchy and what are the desired properties of such a hierarchy? * Write an example of a custom exception inclusion into the hierarchy. -#### Exceptions resources +#### Resources * [Defining exceptions in Haskell](https://www.fpcomplete.com/blog/defining-exceptions-in-haskell) * [Exceptions Best Practices in Haskell.](https://www.fpcomplete.com/blog/2016/11/exceptions-best-practices-haskell) @@ -243,7 +243,7 @@ Should we ban using this pattern? * [Exceptions tutorial from IH book](https://markkarpov.com/tutorial/exceptions.html) Quite hard to read for this level, you would better reread it later. -## [Optional] DataKinds +## (Optional) DataKinds * What is kind? * What is the kind `*`? What is the kind `Type`? @@ -266,7 +266,7 @@ Quite hard to read for this level, you would better reread it later. * [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) -## [Optional] ExistentialQuantification +## (Optional) ExistentialQuantification * What is the main goal of the `ExistentialQuantification` extension? * Can we use constraints for types of quantified constructor parameters? @@ -290,7 +290,7 @@ Quite hard to read for this level, you would better reread it later. * [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) -## [Optional] Extensions Practice +## (Optional) Extensions Practice * Solve kata. * [Count them all!](https://www.codewars.com/kata/5b1bdc2bccef79e948000086) @@ -302,7 +302,7 @@ Quite hard to read for this level, you would better reread it later. * [Test understanding of DataKinds used with TypeFamilies and FunctionalDependencies](../../backend/junior-3/Practice/DataKinds.hs) * [Test understanding of ExistentialQuantification and RankNTypes](../../backend/junior-3/Practice/ExistentialQuantification.hs) -## [Optional] Debugging +## (Optional) Debugging * `Debug.Trace` * How is it useful? diff --git a/format.sh b/format.sh new file mode 100644 index 00000000..1c1a6f26 --- /dev/null +++ b/format.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +themes=$(grep '^## ' ./backend/junior-3/haskell.md | tr ':' ' ' | while read -r theme ; do + echo $theme + themeUid=$(uuidgen) + themeWithUid="${theme} <\!---${themeUid}-->" + $(sed -i "s/${theme}/${themeWithUid}/" ./backend/junior-3/haskell.md) +done) From 5bd14ac990fb9d954ef0c964d2919d0406cc5129 Mon Sep 17 00:00:00 2001 From: olgaklimenko Date: Fri, 11 Feb 2022 16:42:32 +0700 Subject: [PATCH 3/3] temporarily remove ids --- backend/junior-3/haskell.md | 24 ++++++++++++------------ format.sh | 1 + 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/backend/junior-3/haskell.md b/backend/junior-3/haskell.md index cb3d9199..dfa841f0 100644 --- a/backend/junior-3/haskell.md +++ b/backend/junior-3/haskell.md @@ -1,6 +1,6 @@ # Haskell for Junior-3 -## Type classes +## Type classes * Why using constraints on a type variable within a data declaration isn't a good idea? * What is coherence and why is it important to maintain it? What are the possible cases of coherence violation? @@ -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` @@ -60,7 +60,7 @@ * [FPComplete: Functional Dependencies](https://www.fpcomplete.com/haskell/tutorial/fundeps/) -## Type and Data Families +## Type and Data Families * What are the three variations of type families: closed, open, associated? What are their difference and purpose? * What is injectivity? @@ -80,7 +80,7 @@ * [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 +## GADTs * What is the difference between GADT and ADT? * What is the main goal of GADT? @@ -99,7 +99,7 @@ * [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) -## ScopedTypeVariables, Higher ranked types +## ScopedTypeVariables, Higher ranked types * `ScopedTypeVariables` * What is the main goal of this extension? @@ -118,7 +118,7 @@ * [Haskell wiki](https://wiki.haskell.org/Rank-N_types) -## Laziness +## Laziness * What is a reduction strategy? What is an evaluation strategy? How do they differ? * What is lazy evaluation? How it differs from eager evaluation? Is lazy evaluation the same as non-strictness? @@ -203,7 +203,7 @@ * [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) -## Lists +## Lists * What is the difference between `foldl'`, `foldr'` and `foldl`, `foldr`? * How `foldl`, `foldl'`, `foldr` and `foldr'` behave with infinite lists, and why do they have the particular behavior? @@ -214,7 +214,7 @@ * [Fixing `foldl`](http://www.well-typed.com/blog/90/) -## Exceptions +## Exceptions * What is the exception free pattern? * How do we abstract the possibility of failure in Haskell? @@ -243,7 +243,7 @@ Should we ban using this pattern? * [Exceptions tutorial from IH book](https://markkarpov.com/tutorial/exceptions.html) Quite hard to read for this level, you would better reread it later. -## (Optional) DataKinds +## (Optional) DataKinds * What is kind? * What is the kind `*`? What is the kind `Type`? @@ -266,7 +266,7 @@ Quite hard to read for this level, you would better reread it later. * [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) -## (Optional) ExistentialQuantification +## (Optional) ExistentialQuantification * What is the main goal of the `ExistentialQuantification` extension? * Can we use constraints for types of quantified constructor parameters? @@ -290,7 +290,7 @@ Quite hard to read for this level, you would better reread it later. * [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) -## (Optional) Extensions Practice +## (Optional) Extensions Practice * Solve kata. * [Count them all!](https://www.codewars.com/kata/5b1bdc2bccef79e948000086) @@ -302,7 +302,7 @@ Quite hard to read for this level, you would better reread it later. * [Test understanding of DataKinds used with TypeFamilies and FunctionalDependencies](../../backend/junior-3/Practice/DataKinds.hs) * [Test understanding of ExistentialQuantification and RankNTypes](../../backend/junior-3/Practice/ExistentialQuantification.hs) -## (Optional) Debugging +## (Optional) Debugging * `Debug.Trace` * How is it useful? diff --git a/format.sh b/format.sh index 1c1a6f26..aefc819a 100644 --- a/format.sh +++ b/format.sh @@ -2,6 +2,7 @@ themes=$(grep '^## ' ./backend/junior-3/haskell.md | tr ':' ' ' | while read -r theme ; do echo $theme + # add only if no id themeUid=$(uuidgen) themeWithUid="${theme} <\!---${themeUid}-->" $(sed -i "s/${theme}/${themeWithUid}/" ./backend/junior-3/haskell.md)