-
Notifications
You must be signed in to change notification settings - Fork 376
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
Namespaced prefixes — next step for resolving name clashes #122
Comments
I've faced a couple of problems with the new approach. Not sure where better to document them, hopefully this issue is fine.
|
I was thinking, maybe in the future we could start treating all this as a temporal measure for the transition period and go back to using hardcoded names but with prefixes. |
Another issue: how to use FL compatible libraries in the browser (e.g. in jsfiddle)?
|
I'm still not convinced by this, because I don't use Functor.prototype['fl/map'] = function(f) {};
// As an example.
const f = ...
f['fl/map'](x => x); I wonder if there is a way to have both without sacrificing anything?
But this is a tooling/linting issue not actual code issue, because running this doesn't cause any issues. So either we create an alias to solve the tooling/linting issue or we just change the name completely. I'm not a fan of Also @rpominov thanks for the feedback, we should consider all of the above going forward. |
@rpominov |
@SimonRichardson @michaelficarra Yeah, you are right about
I'll open an issue in Flow repo... |
Thanks @rpominov. Please link it here when you do. I'm very interested. |
👍 |
One thing, you're right that Flow doesn't currently support computed keys in a number of scenarios, and can't in general, but in the specific cases where the string literal information can be known statically it's possible. We already support string literal types, which enable this feature. I'll take a look to see if we can easily support this use case. |
@samwgoldman That would be great! So yeah computed names are just strings that come from this file index.js I think it could be possible to statically analyse, at least theoretically :) |
In Fluture I did this thing where I create keys for both |
I think this is the best way to do it, create normal methods in your API like with "old" FL, and then do something like: Type.prototype[FL.map] = Type.prototype.map
Type.prototype[FL.ap] = Type.prototype.ap
... We could even provide a helper that does this automatically: import {makeFantasyLandCompatible} from 'fantasy-land/compat-helper'
makeFantasyLandCompatible(Type) |
Just a curious question: why isn't |
Symbols may cause some pain in legacy JS environments. Also Flow doesn't currently support Symbols for instance. On the other hand it's not clear how Edit: Although Flow doesn't support dynamic method names either. But anyway Symbols may cause problems and don't give anything in return as it seems. |
More discussion on the subject of |
This is done. |
@samwgoldman We now have switched to constant prefixed names, which Flow can support but unfortunately doesn't yet. |
Created an issue in Flow repo facebook/flow#2482 |
So #92 was somewhat resolved with this PR #120
The next step is to eventually publish a version of
fantasy-land
npm package with namespaced prefixed names.There are some questions to discuss though:
Maybe there more questions, these two is what came to my mind.
The text was updated successfully, but these errors were encountered: