shalabh
07/01/2019, 7:40 PMKartik Agaram
shalabh
07/01/2019, 8:09 PMclass Person:
name: string
Now as soon as you deference person.name
you've lost all context - you just have a string. Would be nice to have more meaning attached to the values themselves. You can kind of solve this by newtype/aliasing but it's very clunky and may require defining both a new type and the field with the same name.Miles Sabin
07/01/2019, 8:28 PMname: SomeType
as an element of an HList
with the type Tagged[SomeType, "name"]
where the "name" is a literal type, ie. the singleton type of the String precisely equal to "name".Miles Sabin
07/01/2019, 8:28 PMScott Anderson
07/01/2019, 10:10 PMScott Anderson
07/01/2019, 10:10 PMScott Anderson
07/01/2019, 10:10 PMKartik Agaram
Value types in structures would need to be nominal, not structural. I really don't care if I get a tuple ofThe article is using nominal vs structural in a way that I can sympathize with but haven't seen before. Is, I very rarely care what the machine level types are, what I really want is[Int32, String]
, what the underlying types are doesn't really matter to me.[ProductID, ProductName]
int32
a nominal type because you (often) can't cast it to a boolean? Or is it a structural type because you can use the same operations on it as int64
? Our categories seem to break down at the event horizon of primitive types.
Between this and Rich Hickey's recent critique [1], I feel like I'm seeing the word 'types' with new eyes in 2019.
[1] shalabh
07/03/2019, 4:43 PMshalabh
07/03/2019, 4:51 PMStefan
07/03/2019, 5:01 PMKartik Agaram
Kartik Agaram
Kartik Agaram
Kartik Agaram
shalabh
07/08/2019, 3:32 PMWhat if we required types within interfaces to only be other interfaces?This is somwhat the thing I'm looking for. Maybe it's possible as a design pattern. I feel this idea needs to be provided by the system. One key aspect would be the definition of the 'mapping' between the domain types and the machine types. If this was powerful there's no reason to always clump domain structs together in memory. Perhaps it's also possible have multiple possible underlying representations used in different scenarios for the same domain types and have the system be aware of this mapping. Higher level logic could be written against the domain data model only and optimizations would be defined only in the mappings/hints to machine types.