Concept for the "ultimate dependency notation" #21

Closed
opened 2022-07-23 15:37:45 +00:00 by glen · 0 comments
Owner

The idea is we should be able to just write

export const subtract = {
   'any, any': ({add, negate}) => (l, r) => add(l, negate(r))
}

and for an implementation with no dependencies

export const negate = {
   number: () => n => -n
}

(I don't see a way to make the initial () => to record no dependencies optional,
but that seems like a fairly small price to pay, and being explicit that there are no dependencies isn't terrible.)

And for signature-specific dependencies, this would be:

export const foo = {
	'any': ({'bar(string)':barS, baz}) => arg => expression(barS(arg), baz(arg)
}

This seems to simplify both the dependency specification and the function body so much that it seems well worth switching to.

The implementation idea is actually to call the implementation on a specially-Proxied object that records all the property gets, so it extracts the names of the dependencies.

The idea is we should be able to just write ``` export const subtract = { 'any, any': ({add, negate}) => (l, r) => add(l, negate(r)) } ``` and for an implementation with no dependencies ``` export const negate = { number: () => n => -n } ``` (I don't see a way to make the initial `() =>` to record no dependencies optional, but that seems like a fairly small price to pay, and being explicit that there are no dependencies isn't terrible.) And for signature-specific dependencies, this would be: ``` export const foo = { 'any': ({'bar(string)':barS, baz}) => arg => expression(barS(arg), baz(arg) } ``` This seems to simplify both the dependency specification and the function body so much that it seems well worth switching to. The implementation idea is actually to call the implementation on a specially-Proxied object that records all the property gets, so it extracts the names of the dependencies.
glen added the
enhancement
label 2022-07-23 15:37:45 +00:00
glen closed this issue 2022-07-23 16:59:21 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: glen/pocomath#21
No description provided.