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

Funcadelic casting #3

Closed
taras opened this issue Oct 1, 2017 · 0 comments
Closed

Funcadelic casting #3

taras opened this issue Oct 1, 2017 · 0 comments

Comments

@taras
Copy link
Member

taras commented Oct 1, 2017

I keep seeing a need for some way to cast one type to another.

You can see this in 3 places in current Microstates: Type -> TypeTree, TypeTree -> Transitions, TypeTree -> States.

I'm currently doing this with a static method, but when a TypeClass is created the static method becomes inaccessible.

Something funcadelic might look like this,

import { cast } from 'funcadelic';

let transitions = cast(tree, Transitions);

Internally, it might look something like this:

export const Castable = type(class Castable {});
 
function cast(t, Type) {
   return Castable(Type).cast(t);
}

Castable(Type).cast needs to match t to many potential targets. We don't have a pattern for matching many types to many types of data.

What's the funcadelic way of doing this?

@taras taras changed the title What would a Cast primitive look like? Funcadelic casting Oct 1, 2017
@taras taras closed this as completed Oct 13, 2017
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

No branches or pull requests

1 participant