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

Add Trait definition #4

Open
J3RN opened this issue Nov 26, 2024 · 0 comments
Open

Add Trait definition #4

J3RN opened this issue Nov 26, 2024 · 0 comments

Comments

@J3RN
Copy link
Owner

J3RN commented Nov 26, 2024

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
}
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

No branches or pull requests

1 participant