Skip to content

vine: fn trait [fork/drop] #172

Open
@tjjfvi

Description

@tjjfvi
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    tbdhas open design questionsvine

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions