Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vine: fn trait #172

Open
tjjfvi opened this issue Feb 4, 2025 · 0 comments
Open

vine: fn trait #172

tjjfvi opened this issue Feb 4, 2025 · 0 comments
Labels
tbd has open design questions vine

Comments

@tjjfvi
Copy link
Member

tjjfvi commented Feb 4, 2025

  • replace the current fn(A, B, C) -> D type with an fn F(A, B, C) -> D trait
  • fn foo[T](x: X) -> Y { ... } creates:
    • a unique type fn foo[T]
    • const foo[T]: fn foo[T]
    • impl foo[T]: fn (fn foo[T])(X) -> D
  • fn expressions create unique, unnameable type, with inherent implementation of the appropriate fn trait
  • TBD: how, exactly, do fn impl items work?
fn map[T, U, F; F*, fn F(T) -> I](list: List[T], f: F) -> List[U] { ... }

struct MulBy(N32);

mod MulBy {
  pub impl call: fn MulBy(N32) -> N32 {
    fn call(MulBy(a): N32, b: N32) -> N32 {
      a * b
    }
  }
}

fn curry_mul(a: N32) -> MulBy {
  MulBy(a)
}

curry_mul(2)(23) // 46
@tjjfvi tjjfvi added tbd has open design questions vine labels Feb 4, 2025
@tjjfvi tjjfvi mentioned this issue Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tbd has open design questions vine
Projects
None yet
Development

No branches or pull requests

1 participant