News for hackers. Stuff that matters.
Re:Haskell Typeclasses vs. C++ Classes by tathougies on Tuesday October 17, 2017 @11:06AM (#15491520)
All you need is a GADT which carries around the type class constraint.

    data Object cls a where
      Object :: cls a => a -> Object cls a
Now, the class `cls a` is carried around with the value `a`. You can even go one step further and reify the vtable by itself.

    data Dict c where
      Dict :: c => Dict
which you can't really do in standard C++.

There are no comments on this comment yet.