2 ms·
Since the type was made an instance of the Num typeclass, any function that can be used with Num's, can now be used on the type (Dual d). As per the Prelude[1],
by ttesmer 4y ago
Since the type was made an instance of the Num typeclass, any function that can be used with Num's, can now be used on the type (Dual d). As per the Prelude[1], ^ is part of the Num typeclass. Same thing for * for Floating[2]. The hyperbolic tangent can also be used without being explicitly coded, as it can be derived using cosh and sinh!
EDIT:
As for the differentiation, it works for ^ since it is just multiplication (https://hackage.haskell.org/package/base-4.17.0.0/docs/src/GHC.Real.html#%5E https://hackage.haskell.org/package/base-4.17.0.0/docs/src/G...) for which the derivative was defined using the product rule.
[1]: https://hackage.haskell.org/package/base-4.17.0.0/docs/Prelude.html#v:-94- https://hackage.haskell.org/package/base-4.17.0.0/docs/Prelu...
[2]: https://hackage.haskell.org/package/base-4.17.0.0/docs/Prelude.html#v:-42--42- https://hackage.haskell.org/package/base-4.17.0.0/docs/Prelu...