-
Notifications
You must be signed in to change notification settings - Fork 102
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
Move to prefixed Fantasy Land methods #39
Comments
I am all for supporting Fantasy Land, but are we sure we want to remove the old names? They will still be useful for playing in the REPL, or for code examples (even the Fantasy Land Spec uses them in that context). Plus, I imagine that not all folktale users care about Fantasy Land (some probably just want a safer alternative of promises, for instance) and for them the prefix will be just an annoyance. |
That's a good question. What I want here is to nudge people into moving from This is important for a few reasons:
But you're right about things like code examples and REPL. So perhaps instead of outright deprecating it, we could have an optional warning that asks people to use the function version for their production code, and then you could turn that warning on with something like |
I can definitely agree that having a unified The warnings are a good idea. When I read about them I immediately thought of that UPDATE: An alternative is to just use low log levels for these messages. |
My thoughts about namespaced methods: All libs which require structure to implement some FL interface should depend on FL namespaced methods. this way it would be easy to change one type with other and libs will work together well. so basically I see FL namespaced methods as communication mechanism between libs. But this doesn't means that those libs should not have normal, non namespaced methods. What we should do is make those libs as accessible to all kinde of developers as we can. i think we should just state for each structure which FL interfaces it conforms to, but list only normal non namespaced methods so it's easy to play with and use. I dont see any reason to deprecate or log anything when someone use Also this way maybe we would chiang name of |
I've been thinking about this in the past weeks (work's been eating all my time lately :x), and yeah, there isn't really any reason we couldn't have the methods. It also just struck me that all functions in Fantasy Land use consistent types anyway, so The problem only happens when users are writing generic functions (e.g.: a function that works with any Functor), in those cases, It would be nice if we could warn people of this, but we can't really detect the cases where it matters, so I suppose our best option is (rather than outputting warnings) describing this in the documentation, and recommending people to use the Core.FantasyLand module's functions when writing generic operations. Thanks @boris-marinov and @safareli for the input :) |
Nice 👍 We should state somewhere in doc that if user is writing generic code over any Functor, then FL namespaced methods should be used. Logging might be sort of annoying as it requires configuration, I think just a word in doc will be enough, but it's not that big issue. |
As of 0.3 the Fantasy-Land specification now uses prefixed names (i.e.:
type['fantasy-land/map'](fn)
rather thantype.map(fn)
). Folktale 2 should support this accordingly.Because we're still supporting the same set of features older versions of Folktale do, so people can transition their codebase without as many problems, we'll be using compatibility methods to let people call these namespaced functions. That is, each type will look like this:
We should also encourage people to use the Core.FantasyLand module instead of calling the methods directly when they're writing generic functions (e.g.: a function that works with any functor, rather than just Folktale's Maybe). This direction is documented here: https://github.com/origamitower/folktale/blob/master/ROADMAP.hs#L106-L297
Types that need fixing
See fantasyland/fantasy-land#146 for details on the Fantasy-Land decision.
The text was updated successfully, but these errors were encountered: