如何从mli文件自动生成存根? [英] How to auto-generate stubs from mli file?
本文介绍了如何从mli文件自动生成存根?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一些接口文件mylib.mli
之类的
Suppose I have some interface file mylib.mli
like
var foo : 'a list -> int
val bar : f:('a -> 'b) -> 'a list -> 'b list
val baz : f:('a -> bool) -> 'a list -> 'a list
val frobnitz : init:'acc -> f:('acc -> 'a -> 'acc) -> 'a list -> 'acc
val frobozz : 'a list -> 'a list -> 'a list
val quux : 'a list list -> 'a list
是否有一种自动的方法来生成相应的mylib.ml
作为存根的集合? (存根"是指最小的接口实现功能".)
Is there an automated way to generate the corresponding mylib.ml
as a collection of stubs? (By "stub" I mean a "minimal, interface-implementing function".)
推荐答案
AFAIK,目前没有这样的工具.也许是因为手动进行这项工作并不繁重.编写存根的最简单方法是:
AFAIK, there is no such tool currently written. Maybe, because it is not a big work to do it manually. The easiest way to write a stub is:
let foo = failwith "not implemented"
或者您可以通过以下方式制作
or you can just make it in a following way
let stub _ = failwith "unimplemented"
let foo = stub
let bar = stub
...
这篇关于如何从mli文件自动生成存根?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文