fmease / lushui

The reference compiler of the Lushui programming language
Apache License 2.0
5 stars 0 forks source link

Syntactic sugar for the newtype pattern #85

Closed fmease closed 2 years ago

fmease commented 3 years ago

Currently, it is a pain to define a newtype. Newtypes should be easy to define as they allow users to quickly set up a somewhat type-safe program. Once we decide to use a standard type class system, they will become even more important to properly deal with canonicity.

Example: Newtype User wrapping a natural number (“user id”):

@public
data User: Type of
    user: Nat -> User

(Not too bad actually)

Proposed sugar:

@public
data User: Type = user Nat
fmease commented 2 years ago

Too specific, no clear gain