mlhaufe / brevity

Brevity is a library that enables Feature-Oriented Programming (FOP) and solves the expression problem in a manner that makes data and operation declarations trivial to define and compose.
GNU Affero General Public License v3.0
1 stars 0 forks source link

Investigate Data unification #52

Open mlhaufe opened 1 year ago

mlhaufe commented 1 year ago

Unification is currently implemented as a part of pattern matching in traits.

What if this was lifted into something more first class? What would it enable?

example:

const Point2 = Data({x: Number, y: Number})

const pt1 = Point2(12, _),
    pt2 = Point2(_, 3)

const pt3 = unify(pt1, pt2)

pt3 === Point2(12, 3)
mlhaufe commented 1 year ago

With lazy fields this opens up even more interesting possibilities:

const foo = S({ left: _, right: () => foo })

Is there some logic programming functionality this enables?