-
Notifications
You must be signed in to change notification settings - Fork 233
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
Functor #1
Comments
i'm not sure, but it does look like the proper generic map can be defined at the use sites my current strawman for functor is protocol Functor {
typealias A
typealias FA
typealias B
typealias FB
func fmap(FA,A->B)->FB
} based upon my reading of the spec, anything that defines the "right" generic map functor for itself (which is expressible at the data type defn site), will be construed to have this protocol. But i've not tried yet |
Yeah, i've changed it to have all the type aliases. It will need to be that way. |
theres a twist! i'm having trouble with a toy example
i get the message
|
ahah! got it working
|
The test is whether you can write a function that works on all functors, without repetition. e.g.
|
yup, thats not possible right now afaict :'( |
This actually sounds a lot more harmful than not writing it; it's not just boilerplate, it's more problematic than that. And it's still not clear that the (f b) part can be expressed at all. Sent from my iPhone
|
I think our best hope is to file radars. The developers have acknowledged this and it seems like they'd be open to making these changes. |
Absolutely, if anyone has radr numbers I can add keep track of them on the README. |
Yeah... Until the problems with the language get fixed, I think we should remove |
Using unit types as associated types for ensuring the same functor, I've managed to get something working. There are some weird looking casts, but I think it's actually safe(ish, assuming convention is followed for U).
I'm not quite sure if this is any better than the currently attempted ways at doing it though. Anyone smarter than me have thoughts on it? |
My initial feedback is:
I think there is a correction for
|
Because the general case is impossible, we have settled for a middle ground of brute force and explicit typealiases with more ceremonial than literal meaning. With the bitterness of disappointment in my tools, I will be closing this. |
With these 2 problems:
I propose explicitly providing FA and FB and writing lots of code.
Alternatively, in xsharpx and functional java, you just write map on everything and don't inherit.
I'm not sure what is the best approach. Ideas?
The text was updated successfully, but these errors were encountered: