Created
October 11, 2011 16:10
-
-
Save missingfaktor/1278533 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Consider an example of Show[E] type class. For Show[E], it's possible to have a function f: Show[A] => (B => A) => | |
| Show[B]. The type constructors that support such a function are contravariant functors. | |
| Now, the particular function f is not of interest to us. We are only interested in the fact that it's possible to | |
| implement a function with that signature for the given data type. | |
| I have observed that the data types that are contravariant functors can usually be made contravariant on their type | |
| parameter. Show[-E] for example. If B <: A, then Show[A] <: Show[B]. A few more data types for which I have observed | |
| this pattern: Equal[E], Comparator[E], Resource[E], Function1[E, F] (on E) etc. |
Author
@igstan: It seems function and subtyping are related to a more degree than it seems. I came across this article last night. You might like it: http://apocalisp.wordpress.com/2009/08/27/hostility-toward-subtyping/.
Thanks! Now that the weekend is here I have some time for reading.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So... I understand what you're saying, but I don't yet have an intuition for this stuff. Probably the only ones I can have a feeling for are
Comparator[E]andFunction1[E, F]. I'm now trying to generalize these two in mind. I'll post here if I have some revelation :) Thanks for the (thought) food!