Skip to content

Conversation

@illusory0x0
Copy link

No description provided.

@HCHogan
Copy link

HCHogan commented Aug 11, 2025

I think there’s an important conceptual split that will help the design land cleanly:

Generic traits (multiparam typeclassess/rank-1 polymorphic methods) ≠ Higher-Kinded Types (HKT).

Functor, Monad, ... examples require quantifying over type constructors (Self :: Type -> Type), i.e. Fω/HKT, not just “traits with generic parameters.”

We can split the proposal into to independent capabilities:

Track 1 -- Generic Traits

// Actually fundep `Self Rhs -> Output` is needed to avoid ambiguity
trait HAdd[Rhs, Output] {
  add(Self, Rhs) -> Output;
}

No HKT required.

Track 2 -- Abstraction over type constructors (HKT)

// Self :: Type -> Type
trait Functor {
  fn[A,B] map(Self[A], (A) -> B raise?) -> Self[B] raise?
}

In this way we’ll need:

  • Kind checking & partial application rules
  • Clear inference story (be explicit; HM+HKT inference is hard)

@illusory0x0 illusory0x0 force-pushed the 0004-generics-traits branch from d5dd06e to 3975ba4 Compare October 5, 2025 02:02
- add another author @Erchiusx

- use `skip` to avoid syntax errors
@illusory0x0
Copy link
Author

@HCHogan you are right.

I think this proposal should be divided into three proposals.

The current Self keyword actually supports Kind poly, when writing the MoonBit method.

Related issues:

moonbitlang/core#2433 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants