microsoft/BosqueLanguage

Map's values() function seems to need a different implementation than other functions

brakmic opened this issue · 1 comments

Describe the bug

While I was working on updating the morphir-bosque code to latest Bosque version (I am using it as a good example on how to write proper Bosque code) I ran into a problem regarding the getValues() function. It seems that it got replaced by values() which internally maps to map_values. However, I am unable to implement it by using this schema:

const mtype = this.getEnclosingMapTypeForMapOp(idecl);
const ktype = this.getMapKeyContentsInfoForMapOp(idecl);
const vtype = this.getMapValueContentsInfoForMapOp(idecl);
const vfuncs = this.typegen.getFunctorsForType(vtype);
bodystr = `auto $$return = ${this.createMapOpsFor(mtype, ktype, vtype)}::map_values<${vfuncs.inc}, MIRNominalTypeEnum::${this.typegen.mangleStringForCpp(vtype.trkey)}>(${params[0]});`;
                break;

I have tried different variants but I always get incompatible return types. It seems that the string list I am constructing in map_values isn't compatible with the one Bosque generates.

Also, I think that std::transform in map_values function from bsqmap_ops.h code should not use MEntry<K, V> as return type but only V as this provoked another type error.

However, even after I corrected this one the previous error with incompatible strings remained.

So, the sad result was that I could not provide anything useful for Bosque.

Which leads me to another question: is there any documentation on Bosque internals available? Something that could explain the roles of all those vtype, mtype and various other types and functions like typegen.mangleStringForCpp or MIRNominalTypeEnum::${this.typegen.mangleStringForCpp(rmtype.trkey). And how all those parts interact with each other.

Sometimes there are other variables like rmtype or rmrepr etc. involved.

I have so many questions, I know... :)

The collection library bindings are a bit ugly with a bunch of template parameters derived from the types used and such. There isn't any internals documentation yet and, unfortunately, the collections code is a bunch of carefully balanced mappings of magic values.

I am hoping to get these done myself shortly. Other builtins (like String or Int methods) should have much more obvious implementations and would be a reasonable place to try writing some code.