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

Normalize construction patterns #64

Closed mlhaufe closed 1 year ago

mlhaufe commented 1 year ago

Current state:

traits are PascalCase:

const EvalTrait = trait('evaluate', {
    Lit({ value }) { return value },
    Add({ left, right }) {
        return left.evaluate() + right.evaluate()
    }
})

Data declarations are inconsistent:

const expData = data({
    Lit: { value: {} },
    Add: { left: {}, right: {} }
})

// camelCase or PascalCase?
const peanoData = data((Peano) => ({
    Zero: {},
    Succ: { pred: Peano }
}));

const ListData = data((List, T) => ({
    Nil: {},
    Cons: { head: T, tail: List(T) }
}));

When complected the casing can match:

const List = complect(ListData, [...])

const exp = complect(expData, [...])

// PascalCase?
const peano = complect(peanoData, [...])

data and trait should be consistent as PascalCase, which means data should be a constructor

This implies complect should also produce a constructor and not an instance.