3 ms·
Important (but a little lost in the article) is that in C++, your boxVolume function would compile until you tried to call it with the wrong type. However, the
by spott 12y ago
Important (but a little lost in the article) is that in C++, your boxVolume function would compile until you tried to call it with the wrong type. However, the Haskell version won't compile, even if it hasn't been called.
In C++ templates, instantiating a template on a type that doesn't support the operations needed is a compile error (this is hopefully going to change with concepts), while in Haskell, writing a function requires you to constrain the types that the function operates on to prevent misuse.