Skip to content

Commit 3b39f98

Browse files
Вопросы Middle-1 Haskell Generics
1 parent 4704237 commit 3b39f98

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
@@ -157,24 +157,37 @@ Why is `unliftio` considered safer by the author of `safe-exceptions`?
157157
## Generics
158158

159159
* What is generic programming?
160+
* What methods of generic programming can be used in GHC Haskell? (name at least three)
161+
* How these methods may synergize with other extensions, such as `DefaultSignatures`, `ConstraintKinds`, overlapping instances or others?
160162
* What is `Generic` type class and what is its main goal?
161163
* What is the difference between `Generic` and `Generic1` typeclasses?
162164
* What are the primitive types that can describe all other Haskell algebraic data types (`K1`, `:+:`, etc)?
163165
* How to create default methods of typeclasses for data types that has `Generic` instance?
164166
* What is type family `Rep` and what is its main goal?
165167
* How to get data type name, constructor name, field names (for record fields)?
166168
* Is there a possibility to check if the data type is a `newtype` wrapper?
167-
* Suppose we have `data Example b c = A | B b | C Int c`:
168-
* What is the `Rep (Example b c)` type?
169+
* Suppose we have:
170+
```hs
171+
data Example b c
172+
= A
173+
| B b
174+
| C Int c
175+
| D String (Maybe Int) [Example b c]
176+
```
177+
* What is the `Rep (Example b c)` type? Is there any ambiguity in its definition?
169178
* What would be the result of `to (C 2 "fsd")`?
170-
* How Generic programming can be improved with `ConstraintKinds` extension enabled?
179+
* Advanced question: describe `Rep1 (Example b)` and `to1 (D "ML" Nothing [A, B (), C 3 ()])`.
180+
* How do `PolyKinds` affect `Generic1`?
181+
* 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?
171182

172183
#### Resources
173184

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

180193
## GHCi Debugger

0 commit comments

Comments
 (0)