Taken from typelevel/kind-projector, what's the distinction between:
// partially-applied type named "IntOrA"
type IntOrA[A] = Either[Int, A]
and
// type projection implementing the same type anonymously (without a name).
({type L[A] = Either[Int, A]})#L
?
Are they equivalent?
If a person's statements don't add up, or if they seem to whip out accusations whenever they are uncomfortable, they may be projecting. Another tell-tale sign is when you talk to someone about their behavior or thoughts, and they immediately re-direct the conversation to you or another person.
Here are some signs that you might be projecting: Feeling highly reactive and quick to blame. Difficulty being objective, getting perspective, and standing in the other person's shoes. Noticing that this situation or your reactivity is a recurring pattern.
Here, Freud described projection as a process of evacuating not only excitation but feelings and representations or thoughts which are linked to that excitation. What is projected is then located in the external world and may be experienced by the individual as persecutory, forming the basis of paranoia.
Projection is a psychological defense mechanism in which individuals attribute characteristics they find unacceptable in themselves to another person. For example, a husband who has a hostile nature might attribute this hostility to his wife and say she has an anger management problem.
They are almost equivalent, as it is said in the comment.
Say you have a class trait Super[F[_]] {}
, and you want to implement it where F[x] = Either[Int, x]
You could write:
type IntOrA[A] = Either[Int, A]
class B extends Super[IntOrA] {}
But if you want a one liner, you could write:
class B extends Super[({type L[A] = Either[Int, A]})#L] {}
Or with kind-projector you could write it like:
class B extends Super[λ(A => Either[Int, A])] {}
or even:
class B extends Super[Either[Int, ?]] {}
there is no other difference than making it a one line and having this type anonymous.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With