首页 \ 问答 \ OCaml模块类型和单独编译(OCaml module types and separate compilation)

OCaml模块类型和单独编译(OCaml module types and separate compilation)

我正在阅读OCaml首席设计师1994年关于模块,类型和单独编译的论文。 (在另一个问题上诺曼拉姆齐指着我)。 我明白这篇论文讨论了OCaml目前模块类型/签名系统的起源。 就此而言,作者提出了对签名中的类型声明(允许单独编译)以及清单类型声明(为了表达)的不透明解释。 试图将我自己的一些示例放在一起来演示OCaml模块签名表示法试图解决的问题类型,我将以下代码写入两个文件中:

在文件.mli (或.mli - 我已经试过)( 文件A ):

module type ORDERING = sig
 type t
 val isLess : t -> t -> bool
end

并在文件useOrdering.ml文件B )中:

open Ordering
module StringOrdering : ORDERING
  let main () =
    Printf.printf "%b" StringOrdering.isLess "a" "b"
  main ()

这个想法是希望编译器抱怨(在编译第二个文件时)在模块StringOrdering中没有足够的类型信息来检查StringOrdering.isLess应用程序(从而激发对with type语法的需要)。 但是,虽然文件A按预期编译,但文件B会导致3.11.2 ocamlc抱怨语法错误。 我了解,签名是为了让某人根据模块签名编写代码,而无需访问实现(模块结构)。

我承认,我不确定语法: module A : B ,这是我在这篇相当老的论文中分别编译时遇到的问题,但它让我想知道是否存在这样或类似的语法(不涉及函数)以允许某人仅基于代码编写代码在模块类型上,在链接时提供实际的模块结构,类似于如何在C / C ++中使用*.h*.c文件。 如果没有这种能力,看起来模块类型/签名基本上是用于密封/隐藏模块的内部或更明确的类型检查/注释,但不适用于单独/独立编译。

实际上,查看关于模块和单独编译OCaml手册部分,似乎我与C编译单元的类比被破坏了,因为OCaml手册将OCaml编译单元定义为A.mlA.mli二重奏,而在C / C ++ .h文件被粘贴到任何导入.c文件的编译单元。


I am reading through OCaml lead designer's 1994 paper on modules, types, and separate compilation. (kindly pointed to me by Norman Ramsey in another question ). I understand that the paper discusses the origins of OCaml's present module type / signature system. It it, the author proposes opaque interpretation of type declarations in signatures (to allow separate compilation) together with manifest type declarations (for expressiveness). Attempting to put together some examples of my own to demonstrate the kind of problems the OCaml module signature notation is trying to tackle I wrote the following code in two files:

In file ordering.ml (or .mli — I've tried both) (file A):

module type ORDERING = sig
 type t
 val isLess : t -> t -> bool
end

and in file useOrdering.ml (file B):

open Ordering
module StringOrdering : ORDERING
  let main () =
    Printf.printf "%b" StringOrdering.isLess "a" "b"
  main ()

The idea being to expect the compiler to complain (when compiling the second file) that not enough type information is available on module StringOrdering to typecheck the StringOrdering.isLess application (and thus motivate the need for the with type syntax). However, although file A compiles as expected, file B causes the 3.11.2 ocamlc to complain for a syntax error. I understood that signatures were meant to allow someone to write code based on the module signature, without access to the implementation (the module structure).

I confess that I am not sure about the syntax: module A : B which I encountered in this rather old paper on separate compilation but it makes me wonder whether such or similar syntax exists (without involving functors) to allow someone to write code based only on the module type, with the actual module structure provided at linking time, similar to how one can use *.h and *.c files in C/C++. Without such an ability it would seem to be that module types / signatures are basically for sealing / hiding the internals of modules or more explicit type checking / annotations but not for separate / independent compilation.

Actually, looking at the OCaml manual section on modules and separate compilation it seems that my analogy with C compilation units is broken because the OCaml manual defines the OCaml compilation unit to be the A.ml and A.mli duo, whereas in C/C++ the .h files are pasted to the compilation unit of any importing .c file.


原文:https://stackoverflow.com/questions/9843378
更新时间:2022-12-31 11:12

最满意答案

使用position: fixed代替:

#footer {
    position: fixed;
    background-color: blue;
    width: 100%;
    height: 50px;
    bottom: 0;
}

body {
    overflow-y: hidden;

#mycontent {
    overflow-y: auto;
}

Use position: fixed instead:

#footer {
    position: fixed;
    background-color: blue;
    width: 100%;
    height: 50px;
    bottom: 0;
}

body {
    overflow-y: hidden;

#mycontent {
    overflow-y: auto;
}

相关问答

更多
  • 使用position: fixed代替: #footer { position: fixed; background-color: blue; width: 100%; height: 50px; bottom: 0; } body { overflow-y: hidden; #mycontent { overflow-y: auto; } Use position: fixed instead: #footer { position: ...
  • 有一件事可能在IKImageViewDemo中引起你的兴趣,那就是该图像被放大以适应windowDidResize:方法( [_imageView zoomImageToFit: self] )。 将IKImageView嵌入到NSScrollView中是正确的选择。 为了在调整大小时让滚动条跟随窗口,您需要在Interface Builder中调整弹簧和支撑(== autoresizing mask)。 附录:正如您注意到的那样,Mac OS X 10.6中存在一个导致此问题无法正常工作的错误。 您可以通 ...
  • 只需删除高度属性,你就会得到你需要的东西: http : //jsfiddle.net/kQ5Sm/26/ $("#dialog1").kendoWindow(); var dialog1 = $("#dialog1").data("kendoWindow"); dialog1.setOptions({ width: 500, }); Just delete height property and you'll got exacly what you need: http://jsfiddle. ...
  • 因为你的ScrollViewer在一个StackPanel中,所以它将被给予尽可能多的垂直空间,因为它需要显示它的内容。 您需要使用限制垂直空间的父面板,如DockPanel或Grid。
    解决了!!! 我的鼻子是正确的,但我需要时间才能意识到: this.style.overflow = "hidden"; this.style.left = q/2+"px"; this.style.width = v+"px"; this.style.top = p+"px"; this.style.height = i+"px"; if(this.scrollHeight>this.offsetHeight) this.style.overflowY = "auto"; if(this.scro ...
  • 我想到了。 需要更改以下行: GridData myGrid = new GridData(GridData.FILL_BOTH); // FILL_BOTH instead of FILL_HORIZONTAL I figured it out. The following line needed to change: GridData myGrid = new GridData(GridData.FILL_BOTH); // FILL_BOTH instead of FILL_HORIZONTAL
  • 由于一些冲突规则,您有两个重叠的滚动条(一个用于html ,另一个用于body元素),防止用户点击拖动最重要的滚动条。 快速解决方案是简单地从索引文件中删除overflow-y属性,第25行: 这种行为虽然有点麻烦,因此我将在内部提交一个问题并让我们的团队看一看。 Due to a few conflicting rules you have two overlapping scrollbars (one for html, and the other for the body element) preve ...
  • 解决方案供将来参考:只使用一个重写方法创建IKImageView的子类: -isFlipped() { return YES; } 如果我发现我需要重新实现旋转:(id)方法和类中存在的setImage:(NSImage)方法(并且在旋转的情况下使用由演示者提供的演示),这个子类也将证明是有用的。 Apple)但没有记录,因此没有得到官方支持...... Solution for future reference: Make a subclass of IKImageView with only o ...
  • 溢出属性听起来像你需要的: overflow:scroll; ? 但我想我不确定你对滚动条宽度的不同之处是什么。 如何设置这是可变的? 或者对你的问题进行不同的研究,将div与你的叠加包装器放在另一个div中,让新的div具有scroll属性,这样第一个直接与滚动条无关。 例如:[ 链接 ] 编辑:看看你提供的例子,你想要这样的东西吗? 诀窍就像我上面所说的把div放在一切,但是不给它一个宽度并display:inline-block;它display:inline-block; ( 显示 )所以它适合孩子 ...
  • 小提琴: http : //jsfiddle.net/rYe7V/1/ 只需添加到body : margin: 0; Fiddle: http://jsfiddle.net/rYe7V/1/ Just add to body: margin: 0;

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。