DEV Community

Discussion on: Type holes in TypeScript

Collapse
 
mdarrik profile image
Darrik Moberg

Would you consider doing an edit/follow up using more user friendly variable names? This is super interesting and I just noticed that it was easy to get lost with the filler variables if you weren't reading closely. This can be a problem to new coders/coders from other backgrounds.

I know that you were using the examples from the article you linked, but having a stand-alone series on this could be useful/interesting, especially with a Typescript focus. As someone with 0 Haskell exposure, I found the original article hard to grok.

Thanks for the article.

Collapse
 
gcanti profile image
Giulio Canti

My guess reading the original article is that the naming convention is based on the contraction of the signatures, so

  • (a: A) => B becomes ab
  • (a: A) => number becomes an
  • (an: (a: A) => number) => number becomes ann
  • etc...

Actually it looks good to me as the examples are such a general functions but I'm open to alternatives, what naming convention are you proposing?

Collapse
 
nythrox profile image
Jason Santiago

I personally would use variable names that describe what the values mean and do

function zoop<A, B>(abb: (a: A) => (b: B) => B, b: B, as: Array<A>): B
Enter fullscreen mode Exit fullscreen mode

could be

function zoop<A, B>(reducer: (previousValue: A) => (currentValue: B) => B, initialValue: B, array: Array<A>): B
Enter fullscreen mode Exit fullscreen mode