coalton-lang / coalton

Coalton is an efficient, statically typed functional programming language that supercharges Common Lisp.
https://coalton-lang.github.io/
MIT License
1.15k stars 70 forks source link

Deriving mechanism #10

Open eliaslfox opened 3 years ago

gefjon commented 2 years ago

I'm interested in this, and it seems like it would be a fun way to dip my toes into the compiler (until now I've focused on the standard library). Before I start working, tho, I'd like to know what syntax we'd prefer.

Prior art are Haskell:

data Foo = Bar | Baz deriving (Eq)

and Rust:

#[derive(PartialEq)]
enum Foo {
  Bar,
  Baz,
}

Neither of these has obvious Coalton analogues. My first intuition is to have a separate top-level form derive-instance which looks like:

(define-type Foo Bar Baz)
(derive-instance (Eq Baz))
stylewarning commented 2 years ago

I like the Coalton example syntax a lot.

macrologist commented 1 year ago

+1 for this