Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Type Projection

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?

like image 881
Kevin Meredith Avatar asked Mar 03 '16 19:03

Kevin Meredith


People also ask

How do you know when someone is projecting onto you?

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.

How do you tell if someone is projecting their insecurities?

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.

What is projection according to Freud?

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.

What is example projection?

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.


1 Answers

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.

like image 51
Archeg Avatar answered Sep 29 '22 06:09

Archeg