我不断阅读有关功能的信息:
fun constantly k a = k
但我不明白如何使用它。我试过这样:
val a = constantly 10;
stdIn:32.5-32.28 Warning: type vars not generalized because of
value restriction are instantiated to dummy types (X1,X2,...)
val a = fn : ?.X1 -> int * int -> int
它是这样工作的:
val a = constantly 10 ();
val a : int = 10
但不是这样:
val a = constantly 10;
a ();
stdIn:36.1-36.5 Error: operator and operand don't agree [tycon mismatch]
operator domain: ?.X1
operand: unit
in expression:
a ()
任何人都可以帮助我理解该功能吗?