I review GHC's three mechanism for type-aware programming -- Typeable, Data, and Generic -- covering what they do and how to choose between them. Find me at richarde.dev/ or on Twitter at @RaeHaskell Video index at richarde.dev/v...
Ok, I tried out `eqTypeRep` and `==`. The simple == doesn't work for this example, but it might be OK in other cases. Using `eqTypeRep`, the type equality becomes visible to the compiler. Using the Eq instance of `TypeRep` implies that the type equivalence isn't available at compile-time, only at runtime and thus I can't use the fact that x is an `Int` later in the code.
Thanks, this was the best video on the topic that I could find, very useful and to the point, with enough pointers to look deeper into specific aspects for anyone interested
Thanks for this video. Generic programming *terrified* me until I had a go and wrote some generic binary codecs (a la Aeson but for binary data). Made me a lot more comfortable with all the type level features of Haskell, and removed my fear of UndecidableInstances. The sort of high level algebra you're forced into feels like the real meat of Haskell, stuff you can't do in other languages (at least not with the same safety guarantees). When the code you're writing is directed by the structure of the type(s) involved, you can likely exploit Generic.