4 ms·
Anywhere you see a "deriving" clause is a place where macros would have probably have sufficed instead of requiring support from the compiler.
by xrange 10y ago
Anywhere you see a "deriving" clause is a place where macros would have probably have sufficed instead of requiring support from the compiler.
- coolsunglasses 10y agoThe deriving (and related generics) functionality is quite a bit cleaner and more appropriate to the problem than macros.
- marcosdumay 10y agoExcept when you want to derive something that isn't supported by the compiler, and isn't creating a newtype.
- coolsunglasses 10y agoSo you haven't used Haskell? I can use `Generic` or TH to derive anything for anything I want. In the case of the latter, it doesn't even have to be a typeclass instance.
- js8 10y agoI think "would have sufficed" is a strange choice of words in this case. I do consider macros a lot stronger than "deriving", but I am not sure they are entirely appropriate in a language which is so much rooted in type theory as Haskell is. I think of "deriving" in Haskell as a form of automated theorem proving, and I think it would be beneficial to have better theorem prover integrated in the language (I think it is in languages like Coq). The reason why I think theorem prover would be more appropriate than macros is because with macros you, as a programmer, have to do the proof explicitly, and you're responsible for it being type correct. Whereas with a real theorem prover behind the scenes, this work is not needed. In general, I think it's still quite unclear how to well integrate macro system of Lisp power with type checked language. So risking "moving the goalpost", I am not really satisfied with your answer. Are there some uses cases for macros that do not involve theorem proving (i.e. having compiler build some function automatically based on type signature alone)?