r/ProgrammingLanguages • u/Uncaffeinated 1subml, polysubml, cubiml • Apr 02 '26
Language announcement 1SubML - structural subtyping, unified module and value language, polynomial time type checking and more
https://github.com/Storyyeller/1subml?tab=readme-ov-file
55
Upvotes
25
u/Uncaffeinated 1subml, polysubml, cubiml Apr 02 '26
This is the language I've been working on since August which I previously described on my blog as X (though some things have changed since the initial plans described there.)
This is the latest evolution of my previous programming languages Cubiml and Polysubml. This time, the most notable new features are modules, imports, newtypes, implicit coercions, type witnesses, and complex pattern matching. Additionally, I fixed the issues with Polysubml's polymorphism by switching to the new "spine constructor" system for polymorphic types.
12
u/phischu Effekt Apr 02 '26
Holy shit, this is extremely impressive. I hadn't thought this combination of features is possible to implement. This "Pinning and Aliasing" and the "Record Spine Constructors" things I have not seen before, are they novel? I am no expert in these corners of type checking, but they seem to be very elegant solutions to big problems.
9
u/vanderZwan Apr 02 '26
So working my way through the introduction I see that you have something in common with Pony:
In Pony it's called a "destructive read", if you search for it on this tutorial page you'll find it. Like you they mention the convenience for swapping values, but also allude to it being useful in their capabilities-secure type system (I admit I've never actually written Pony code and struggled with understanding the docs long before reaching the part where they explain it, so I don't know about those myself). Do you have any deeper use for this in the more advanced language features too?
4
u/paldepind Apr 02 '26
This looks very cool. How is first-class modules implemented? The name gives the impression that it might be similar to 1ML (by Andreas Rossberg et al.). Is that the case?
4
u/oberblastmeister Apr 02 '26
One of the main features of 1ml is that you can project types from modules without unpacking existentials, even though 1ml elaborates modules to existential and universal types. For example you can define a function
mconcat : (M : Monoid) -> list M.t -> M.t. Does your language support this feature?4
u/emekoi Apr 03 '26
i read over the description of spine constructors and i'm not sure i understand the point. are they simply an optimization? i'm thinking that for types
τ₁andτ₂, if we knowspine(τ₁) ≠ spine(τ₂)then there is no way thatτ₁ ⊑ τ₂which sounds like a pretty cool trick even if you aren't using 1SubML. in the setting of unification, this means that you only need to unification on the spines (parameters) without having to traverse the whole type.though i suppose this is a necessity for equirecursive types and simply corresponds to clever way of writing out these graphs that gives us quick access to the information we care about. however, i'm not sure how much of this last part is actually applicable to 1SubML.
3
u/leddy231 Apr 02 '26
This looks cool! Im gonna try to learn from the type checker for sure.
Im not too familiar with the ML family and im curoius about the modules becaude I never reallt got them, they just seemed like structs/objects to me. What makes them special? What does the mod keyword do for example?
I tried translating the Counter example to typescript:
Is that roughly equivalent? apart from in TS you needed to define the generic variables up front.
6
u/vanderZwan Apr 02 '26
literally unusable /j.
Seriously though, this looks really cool! And I feel like half of the features described are things completely new to me, so I'm looking forward to read the language guide and learn about both the language and the concepts it supports!