在SML中调用Python函数
我试图从我在SML中编写的python文件中调用一个函数。我收到tycon失配错误,我不明白为什么。这是我的SML代码在SML中调用Python函数,python,python-3.x,call,sml,smlnj,Python,Python 3.x,Call,Sml,Smlnj,我试图从我在SML中编写的python文件中调用一个函数。我收到tycon失配错误,我不明白为什么。这是我的SML代码 fun interpreter(inFile: string, outFile: string)= let val s = interpreter(inFile, outFile) in OS.Process.system ("python interpreter.py" ^ s) end; 这就是我收到的错误 - use "in.sml"; [opening
fun interpreter(inFile: string, outFile: string)=
let
val s = interpreter(inFile, outFile)
in
OS.Process.system ("python interpreter.py" ^ s)
end;
这就是我收到的错误
- use "in.sml";
[opening in.sml]
in.sml:1.6-6.6 Error: right-hand-side of clause doesn't agree with function result type [tycon mismatch]
expression: ?.OS_Process.status
result type: string
in declaration:
interpreter =
(fn (<pat> : string,<pat> : string) =>
let val <binding> in OS.Process.system <exp> end)
val it = () : unit
编译器正在尝试协调您在此处递归调用的
解释器的结果/返回类型:val s=interpreter(infle,outFile)
。编译器认为s
必须是string
类型,因为您将其与^
连接,但函数体返回的值必须是OS.Process.system(“python解释器.py”^s)
返回的值,该值必须是?.OS\u Process.status
确定,那么,我将如何使用从SML函数收到的参数在python中调用该函数呢?我是否可以去掉连接,使其OS.Process.system(“python解释器.py”)
?这允许sml程序编译并返回我这个val解释器=fn:string*string->Word32.word val it=():unit
我的python程序应该输出一个文本文件,Word32.word也是我应该期望的输出吗?重复的。请提问一次。请用缩进而不是反勾来格式化代码块。如果您选择文本并按下{}
按钮,它通常会做正确的事情。这永远不会终止,因为评估取决于它自己的结果。
def interpreter(input, output):
x = Interpreter()
x.interpreter(input, output)