'How do I verbalize the term F[_] in scala/cats-effect
I'm learning the concept of F[_] as a constructor for other types, but how do you pronounce this to another human or say it in your head (for us internal monologue thinkers).
Similar to how x => x + 1
has an official verbalization of "x goes to x plus one", how does my internal monologue parse def stream[F[_]: Async]: Stream[F, Nothing] = ...
?
Edit: I've taken to calling it "Flunderscore" but I'm legit worried that if I keep doing this I'm going to screw up and say this in a professional context. Plz help.
Solution 1:[1]
Generally speaking that's an effect or program, but I found program to be more understandable when explained out of the context of FP; in a functional way of thinking, we can consider every value as a program, and every program as value, so We can think of it in terms of programs that create programs.
for instance:
- the following is a program that for any program type F, takes an integer and creates a F program that outputs an integer
def foo[F[_]](i: Int): F[Int] = ???
which is an absurd program (can't be implemented)
- the following is another program, that for any program type F that can be composed sequentially, takes an integer and returns a F program that outputs an integer
def bar[F[_]: Monad](i: Int): F[Int] = ???
Note that types like List[T]
and other containers are also programs, that output a sequence of values.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | hnaderi |