3 ms·
If you have Obj f(Obj a, Obj b); in C++, you pass in Obj's vtable twice, and the returned value includes a vtable. If you have f :: Obj a => a -> a
by lalaithion 6y ago
If you have
Obj f(Obj a, Obj b);
in C++, you pass in Obj's vtable twice, and the returned value includes a vtable.
If you have
f :: Obj a => a -> a -> a
in Haskell, you pass in one dictionary. If you have
f :: (Obj a, Obj b) => a -> b -> a
in Haskell, you pass in two dictionaries. If you have
f :: (Obj a, Obj b, Obj c) => a -> b -> c
you pass in three dictionaries, and the caller gets to decide what the concrete type of c is, NOT the function implementation.
data DynObj = forall c. Obj c => DynObj c
f :: (Obj a, Obj b) => a -> b -> DynObj
In this case, you pass in two dictionaries and the returned value has a vtable. This essentially is what C++ does.