I know about the existence of
But is there a more generic function to convert any
Num to the
I'm also aware of the fact that
Num is a set of types, and possibly that comes with limitations of how to use it.
But it is possible?
fromNum::(Num a) => a -> Double
And preferably, without installing any additional packages.
There is absolutely not a way to do this, and for a very good reason.
Num is a generic type designed to be used for anything vaguely "addable" and "multiply-able". You can very loosely think of it as a ring. This means that things like vectors, points, and matrices are
Num. And there's no reasonable, canonical way to convert a
Matrix a into a
You've already noted that there are several ways to get to
Double from more specific typeclasses like
fromInteger is also on
Num. That's largely considered a misfeature and libraries doing things with matrices usually just provide an awkward default implementation.