types - QueΛ的投影算子是什么类型?

标签 types functional-programming operators ocaml

铃木、Kiselyov 和 Kameyama 最近的论文 Finally, Safely-Extensible and Efficient Language-Integrated Query它们给出了嵌入 OCaml 中的类型安全、可扩展查询语言的规范,可以将其转换为 SQL。

这是他们用于查询的代数,摘自论文。

module type Symantics = sig
    type α repr (* representation type *)

    val int: int → int repr
    val bool: bool → bool repr
    val string: string → string repr

    val lam: (α repr → β repr) → (α→β) repr
    val app: (α → β) repr → α repr → β repr

    val foreach: (unit→ α list repr) →
                 (α repr → β list repr) →
                 β list repr
    val where: bool repr → (unit → α list repr) → α list repr
    val yield: α repr → α list repr
    val nil: unit → α list repr
    val (@%): α list repr → α list repr → α list repr (* bag union *)

    val (=%): α repr → α repr → bool repr

    ... (* abbreviated *)

    type α obs (* observation *)
    val observe: (unit → α repr) → α obs
end

本文稍后使用的投影运算符(%.)被剪断在标记为缩写的部分中。文字说:

We use the symbol @% for [bag union], =% for equality test, and %. for projection, whose typing is elided for brevity. See our code for more details.

我尽职尽责地查看了the code ,但是%.的声明却不见了。

%. 的正确类型是什么?它是否从代码的最终版本中删除了?如果是的话,是什么取代了它?

最佳答案

我想,是在 quel_sql.ml

val ( %. ) : ('a -> 'b term) -> string -> 'a -> 'c term

该文件没有相应的 .mli,OCaml 自己推断模块的签名。您可以将生成的cmo文件加载到顶层,使用ocamlbrowser或merlin来获取该符号的签名。我做了第一个并在此处复制粘贴了签名,因此它不会出现在源中(您不会找到它)。

关于types - QueΛ的投影算子是什么类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35205954/

相关文章:

android - 兼容数据类型

haskell - J/K/APL 如何按照通用范式进行分类?

operators - ArangoDB - 带有 "!="运算符的数据库索引

Scala - 定义自己的中缀运算符

vba - 为什么要在 VBA 类模块中声明新类型?

javascript - 对返回对象中的键值使用进行类型检查

c - POSIX/SUS header 中的类型定义

haskell - 纯函数式语言中的高效堆

clojure - 无法更改/建立 : [some-def] with set in Clojure 的根绑定(bind)

C 编程 : Confusion between operator precedence