Skip to content

Add Trait definition #4

@J3RN

Description

@J3RN

We need to be able to define new Traits. Haskell's typeclass definition looks like:

class Show a where
  show :: a -> String

There's a variety or reasons why I don't like this syntax.

Rust's trait definition looks like:

pub trait Summary {
    fn summarize(&self) -> String;
}

This is closer to what I want (but obviously pub goes away and &self should (not be borrowed) and have a better name like object or something. And I don't like the fn keyword either.

Perhaps something like this:

trait Summary {
  summarize : a -> String
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions