Generic type annotation in F#

后端 未结 2 1268
面向向阳花
面向向阳花 2021-01-21 01:46

I got the following error:

Error 2 Value restriction. The value \'gbmLikelihood\' has been inferred to have generic type val gbm

2条回答
  •  星月不相逢
    2021-01-21 02:25

    Instead of making the parameters of gbmLikelihood explicit you might also just add a generic type annotation to the function:

    let gbmLikelihood<'a> = 
        likelihood (fun data p -> Array.get p 0) (fun datac p -> Array.get p 1)
    

提交回复
热议问题