Page MenuHomePhabricator

Generic types
Open, HighPublic

Description

We introduce generic types. This requires the following tasks:

  • functions that take types as an argument and return a type can be implemented and evaluated (the result of such a function call is called a generic type)
  • a function call can be used as the type of an instance (i.e. instances of generic types can be created manually)
  • functions that take types as an argument and return a function can be implemented and evaluated (the result of such a function call is called a generic function)
  • functions created by a function can be evaluated (i.e. generic functions can be called)
  • instance validation (i.e. generic functions can be used as validators for generic types,)
  • instance validation works (i.e. I cannot store an instance of a generic type that does not pass validation)
  • instances of generic types are displayed correctly in the UX
  • functions using generic types as their input or output types can be defined and implemented

This goes hand in hand with changing the data-model to the full data model, in particular:

  • change Z10/List from a type to a function taking a type
  • change Z8/Function from a type to a function taking a list of types and a type
  • change Pair to take two types (note that this is currently on Z22, needs to be updated first)
  • update Z4K2 to take a list of Z3s, Z4K3 to the proper Z8, Z8K1 to a list of Z17, Z8K2 a list of Z20, Z8K3 a list of Z16, Z12K1 to Z10(Z11), Z22K1 to Z10(Z21), Z50K1 to Z10(Z3)
  • the builtin functions need to change their signatures as well

Once the move to Z8 is done, we can significantly tighten the validation of Z7s. Especially, in a composition or function call,

  • every argument with a literal should be compatible with that literal
  • every argument with a function call should be compatible with the return type of that function call
  • every argument with a function reference should be compatible with that function reference

Related Objects

StatusSubtypeAssignedTask
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
DuplicateNone
OpenNone
OpenNone
OpenNone
OpenDVrandecic
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
Resolvedgengh
DeclinedLindsaykwardell
ResolvedLindsaykwardell
Resolvedcmassaro
Resolvedcmassaro
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
Resolvedcmassaro
ResolvedDVrandecic
ResolvedDVrandecic
ResolvedDVrandecic
ResolvedDVrandecic
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenSimoneThisDot
OpenSimoneThisDot
OpenNone
OpenSimoneThisDot
Opencmassaro
Resolvedcmassaro
Resolvedcmassaro
Resolvedcmassaro
ResolvedJdforrester-WMF
ResolvedDVrandecic
ResolvedDVrandecic
In Progresscmassaro
ResolvedBUG REPORTJdforrester-WMF
OpenDVrandecic
OpenNone
OpenNone
Resolvedcmassaro
OpenNone
OpenNone
OpenNone
OpenNone
ResolvedJdforrester-WMF
ResolvedDVrandecic
OpenNone
StalledNone
ResolvedDVrandecic
Resolvedgengh
OpenNone
ResolvedDVrandecic
OpenNone
ResolvedJdforrester-WMF
OpenNone
OpenNone
Resolvedcmassaro
ResolvedDVrandecic
ResolvedLindsaykwardell
Resolvedarthurlorenzi
ResolvedNone
InvalidNone
Resolvedcmassaro
Resolvedcmassaro
Resolvedcmassaro
Resolvedcmassaro
Resolvedcmassaro
ResolvedJdforrester-WMF
Resolvedcmassaro
Resolvedcmassaro
Resolvedcmassaro
ResolvedNone
OpenNone
OpenSimoneThisDot
ResolvedSimoneThisDot
OpenNone
OpenNone
OpenNone
ResolvedNone
ResolvedDVrandecic
OpenNone
OpenNone
OpenNone
Resolvedgengh
Resolvedcmassaro
ResolvedJdforrester-WMF
ResolvedAdesojiThisDot

Event Timeline

DVrandecic raised the priority of this task from High to Unbreak Now!.
thiemowmde lowered the priority of this task from Unbreak Now! to Needs Triage.Mar 2 2021, 8:43 AM
thiemowmde added a subscriber: thiemowmde.

@DVrandecic A priority as extreme as "unbreak now" for an otherwise normal task appears to be a mistake. See https://www.mediawiki.org/wiki/Phabricator/Project_management#Priority_levels.

@DVrandecic I'm trying to work through an example of how, for example, a list of strings would be implemented; is there a document anywhere we have that goes into this in detail? The sticking point I'm on is what would the keys for a specific value of the generic type look like. If the generic list type function is Z9999, then its main key (Z9999K1) would be just the type of the list, right? But that specific value of the type would also have keys - for a list it has "Head" and "Tail" keys. Presumably when you do the function call with Z9999K1 = Z6 (string) then it returns a Z4 object that looks a bit like our current Z10, but with the type for key Z10K1 as Z6 instead of Z1, etc. But how would the "Z10K1" key be referred to now? That is, in this section of what is now in Z10:

"Z1K1": "Z3",
"Z3K1": "Z1",
"Z3K2": "Z10K1"
"Z3K3": { ...

the function call would return an object like this but with "Z1" -> "Z6", but what happens to the "Z10K1" piece? Just "K1"? Something else? We need some way to specify the keys for the actual instance objects of this type!

Of course this is a very general problem - how do you supply the arguments to a function that is returned from a function call (or perhaps just constructed in place), rather than being a persistent ZObject with an id? Do we have any kind of general solution for this now? I was looking through documentation on metawiki and couldn't find anything...