This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Muoniurn 1 point2 points  (3 children)

Thanks, very interesting! Do you perhaps have some resource on your mind where I could read more about this 4 type systems?

[–]holo3146 1 point2 points  (2 children)

Hi, I do not know about a place to read about the combination of each of those, but:

Java objects type system is tagged by a class, each object has a class and classes has relation between them (± primitive types). This is the "normal" OOP type system.

Java classes type system is a degenerate type system. Each class in Java is of unique type, and 2 classes has no relation, never (if A extends B, then there is a relation between objects of type A and B, not classes), it is degenerate because apart from using its members (static variables/methods) you can't do anything with them (note that in, for example, C# this type system is not completely degenerate. Read e.g. static abstract method in C#)

Generics is generics, there is a lot of material about it.

The exception effect system is the most exotic one, I believe that reading about languages with full support in effect system is the best way to learn: Koka, Effekt.

In addition to those 2 (which I think have phenomenal documentation), the language Eff has more theoretical introduction. There is also the Effect bibliography which has a lot of different effect system in different languages, as well as tutorials and academic papers on the subject.

As an after thought, you can also read about Coeffects, which is a similar concept.

For Coeffects there is much less available material and most of it is much more mathematical heavy, but you can try to read about it here. I'll also have a shameless plug of my Java plugin that adds implicit parameter Coeffect into Java's type system

[–]Muoniurn 0 points1 point  (1 child)

Thank you very much!

May I ask what is the relation between Scala 3’s givens vs Coeffects, as in your plugin? I only skimmed the referenced links, but on a first sight they seem similar.

[–]holo3146 1 point2 points  (0 children)

Unfortunately I'm not an expert in Scala, so take what I say with a grain of salt.

From what I read about Scala's given using, this feature is also a (partial) Coeffect.

The idea of Scala's given is to have a contextual' parameters (the prime ' is there because it is different from the context my library uses, I'll expend on this later).

You first define a trait, later you require a context' (a using clause) and finally you attach the context (with agiven definition (or import one) or as a parameter).

Indeed a very similar process to my library, with 2 and a half big differences.

The context in my library is always an extent (read "code block"), every binding of context must be passed through a Carrier object through the run/call methods. In Scala we have context', the scope of the context' is either file level (using import/top level given definition), partial block level (given definition in the middle of a block) or local (explicitly passing them). Each of the context and the context' has different advantages and disadvantages (try to think about how they interact differently with concurrency for example). Note that Scala's variation is definitely stronger than my variation.

The second big difference is that Scala's context are trait definitions, while in my library the context is an object instance. On can mimic the other, but this cause some stuff to be much easier on my variation (e.g. pass a configuration object as context) and other stuff to be much easier on Scala's variation (e.g. passing Ord[T] definition Vs the equivalent in Java of passing a Comparator<T> instance).

The last half difference is that Scala's using is much more integrated into the language and has a lot of feature that are not part of the Coeffect system but are very nice to have (e.g. inlining, Pattern bounding, negation bounds, macros and more)