5

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.

WhiteleyJ
  • 1,393
  • 1
  • 22
  • 29
  • 1
    It is just an special use case of a kind with one type paramter. Also professionally, just calling it `F` is totally fine. – sarveshseri Dec 24 '21 at 02:46
  • 4
    When in the context of cats-effect I just call it the "effect" type – Dylan Dec 24 '21 at 04:24
  • Usually F type, or higher kinded type of F if you wanna mention the higher kind. If you wanna go mathematical, I sometimes call it F domain – SwiftMango Dec 24 '21 at 05:46
  • You can call it a *type constructor*. The same way a constructor constructs a class, a type constructor, given a type parameter, constructs a type. – Yuval Itzchakov Dec 24 '21 at 07:32
  • 1
    Usually, I would use the word _"effect"_ or _"program"_ for the `F[_]` and _"capability"_ for the evidence. Thus, I would say: `stream` is a method parametric in any effect type `F[_]` as long as there exists the capability `Async` for such type, and it will return a `Stream[F, Nothing]` – Luis Miguel Mejía Suárez Dec 24 '21 at 12:50
  • FWIW I don't think I've ever heard "x goes to ..." either. But I'm not a native English speaker. – Jasper-M Dec 24 '21 at 13:35

1 Answers1

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:

  1. 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)

  1. 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.

hnaderi
  • 91
  • 1
  • 1
  • 5