Vicente J. Botet Escriba
Hi Louis,
There is a lot of very good work on your library.
Thank you!
I have some comments in relation on how I have implemented Type Classes in my prototype.
You wrote a type class emulation in C++? Could you please share the link; I'd like to have a look!
About datatype<T>. The library proposes type classes and data types. The name datatype_t<> is confusing as the datatype<T> meta-functions must not return one of the defined data types. I see it much more as a category, which is used to map the data type to a category used as parameter of the instantiation
TC::Instance
.
IIUC, you're pointing out that `datatype_t
In addition, I wonder if the category associated shouldn't depend on the type class we want to map.
TC::Instance
>
I'm not sure why that would be useful. Do you have a use case in mind?
About naming: Haskell doesn't have namespaces and all the functions are at the same scope. Your library makes use of a lot of non-member functions, and so name clashing must be avoided. What about moving all the non-member functions of the Type Class to a specific namespace? E.g.
struct Monad { ... };
namespace monad { using namespace applicatives; ... bind() };
The use would need to use the type class namespace explicitly
auto x = monad::bind(m, f)
or introduce the namespace of the type class
using namespace monad; auto x = bind(m, f);
I had not thought about the issue because right now, name clashing is avoided simply by not having two functions with the same name. This has worked well so far. Since this is the simplest way to do things, I'd rather keep it that way. Of course, if I need to introduce a function whose name would clash, then I will strongly consider your suggestion; thank you for that. Regards, Louis