reanalyze icon indicating copy to clipboard operation
reanalyze copied to clipboard

decorating functions in pipe chains?

Open AlexMoutonNoble opened this issue 2 years ago • 4 comments

Hi Christiano and all Wondering if youve considered decoration for functions called in pipe chains? I wasnt able to add the decorator where I thought it would go

Thanks for the quick feedback about literal divides. Alex

AlexMoutonNoble avatar May 23 '22 20:05 AlexMoutonNoble

Hi, do you have an example?

cristianoc avatar May 23 '22 22:05 cristianoc

  if columns->Js.Array.length >= 2 {
    let dataRecordIdColumn = @doesNotRaise columns->Belt.Array.getExn(0)
   ...
  }

AlexMoutonNoble avatar May 23 '22 23:05 AlexMoutonNoble

One can annotate the function Belt.Array.getExn or the result of the application. In the case of pipe, there are issues with the parsing of the annotation.

See examples in https://github.com/rescript-association/reanalyze/pull/165

This should be moved to an issue in the https://github.com/rescript-lang/syntax repository: 1 (@doesNotRaise [])->Belt.Array.getExn(0) formats to @doesNotRaise []->Belt.Array.getExn(0) so this is annotating the argument not the result 2 @doesNotRaise ([]->Belt.Array.getExn(0)) formats to []->Belt.Array.getExn(0) so it completely destroys the annotation.

For your workaround, you can annotate the function for now.

cristianoc avatar May 24 '22 04:05 cristianoc

Rad. Thanks for the examples. I need to take more time looking in there as well

AlexMoutonNoble avatar May 25 '22 17:05 AlexMoutonNoble