如何在Idris REPL中编写函数?如果我在REPL中输入函数定义longer: string -> string -> string,我会得到以下错误信息:
(input):1:7: error: expected: "$",
"&&", "*", "*>", "+", "++", "-",
"->", ".", "/", "/=", "::", "<",
"<$>", "<*", "<*>", "<+>", "<<",
"<=", "<==", "<|>", "=", "==",
">", ">=", ">>", ">>=", "\\\\",
"`", "|", "||", "~=~",
ambiguous use of a left-associative operator,
ambiguous use of a non-associative operator,
ambiguous use of a right-associative operator,
end of input, function argument
longer: string -> string -> string<EOF>
^发布于 2017-07-12 21:32:32
Idris documentation提供了您所需的示例。您应该使用:let命令。如下所示:
Idris> :let longer : String -> String -> String; longer s1 s2 = if length s1 > length s2 then s1 else s2
Idris> longer "abacaba" "abracadabra"
"abracadabra" : String默认情况下,Idris REPL不会执行任何智能操作,当您输入函数类型时,它不会进入智能多行模式。:let命令用于在REPL中定义任何顶级绑定。
另一个时刻:如果你想使用字符串类型,你应该使用String (以大写字母开头)而不是string。
https://stackoverflow.com/questions/45054824
复制相似问题