Skip to content

Add Trait definition #4

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
}

Activity

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

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