Skip to content

Commit 3f2c636

Browse files
authored
Merge pull request #356 from fullstack-development/haskell-middle-1-generics
Вопросы Middle-1 Haskell Generics
2 parents 5b92710 + 3b39f98 commit 3f2c636

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

backend/middle-1/haskell.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,24 +177,37 @@ Why is `unliftio` considered safer by the author of `safe-exceptions`?
177177
## Generics
178178

179179
* What is generic programming?
180+
* What methods of generic programming can be used in GHC Haskell? (name at least three)
181+
* How these methods may synergize with other extensions, such as `DefaultSignatures`, `ConstraintKinds`, overlapping instances or others?
180182
* What is `Generic` type class and what is its main goal?
181183
* What is the difference between `Generic` and `Generic1` typeclasses?
182184
* What are the primitive types that can describe all other Haskell algebraic data types (`K1`, `:+:`, etc)?
183185
* How to create default methods of typeclasses for data types that has `Generic` instance?
184186
* What is type family `Rep` and what is its main goal?
185187
* How to get data type name, constructor name, field names (for record fields)?
186188
* Is there a possibility to check if the data type is a `newtype` wrapper?
187-
* Suppose we have `data Example b c = A | B b | C Int c`:
188-
* What is the `Rep (Example b c)` type?
189+
* Suppose we have:
190+
```hs
191+
data Example b c
192+
= A
193+
| B b
194+
| C Int c
195+
| D String (Maybe Int) [Example b c]
196+
```
197+
* What is the `Rep (Example b c)` type? Is there any ambiguity in its definition?
189198
* What would be the result of `to (C 2 "fsd")`?
190-
* How Generic programming can be improved with `ConstraintKinds` extension enabled?
199+
* Advanced question: describe `Rep1 (Example b)` and `to1 (D "ML" Nothing [A, B (), C 3 ()])`.
200+
* How do `PolyKinds` affect `Generic1`?
201+
* What are `Generic`'s limitations? Are there any data declarations that cannot be represented with this machinery? Is there any alternative for handling these in a generic fashion?
191202

192203
#### Resources
193204

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

200213
## GHCi Debugger

0 commit comments

Comments
 (0)