Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Transition composition type #453

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

estum
Copy link

@estum estum commented Feb 11, 2023

It is a composition type, where the left type is an intermediary one and
the right type is a resulting.

It differs from an Implication by an input for the right type: instead of bypassing the original input, it will pass a coerced result of the left type. The same effect is possible with a Constructor but Transition allows to keep a transitive object as type instead of function.

When the left type if failed it bypasses input value to the right type.

The meta is always stored and get from the right-hand type, because the left type is not the target.

Here is a real-world example, that I use, note a combination with implication:

Callable = Types.Interface(:call)
Aref = Types.Interface(:[])
CallableAref = Callable <= (Aref > Types.Constructor(Proc, proc(&:[]).curry(2)))

CallableAref[[1,2,3]][0] # => 1
CallableAref[proc(&:nonzero?)][0] # => nil

@flash-gordon
Copy link
Member

I like the idea but haven't looked into the implementation yet. However, I think <= is redundant. Shouldn't >= suffice?

@flash-gordon
Copy link
Member

By the way, not to discourage you but pls submit a question about adding new features on the forum first. It would be a shame if you spend a lot of your time on something that is rejected (or requires a lot of modification) for whatever reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants