Skip to content

Instantly share code, notes, and snippets.

@missingfaktor
Created October 11, 2011 16:10
Show Gist options
  • Select an option

  • Save missingfaktor/1278533 to your computer and use it in GitHub Desktop.

Select an option

Save missingfaktor/1278533 to your computer and use it in GitHub Desktop.
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.
@igstan
Copy link

igstan commented Oct 11, 2011

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] and Function1[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!

@missingfaktor
Copy link
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/.

@igstan
Copy link

igstan commented Oct 14, 2011

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