OCaml

来自开放百科 - 灰狐
(版本间的差异)
跳转到: 导航, 搜索
(链接)
 
(未显示1个用户的4个中间版本)
第14行: 第14行:
 
[[ML]] 家族的两个主要的方言是 Standard ML 和 OCaml。
 
[[ML]] 家族的两个主要的方言是 Standard ML 和 OCaml。
  
==Windows==
+
==功能==
*[https://protz.github.io/ocaml-installer/ OCaml on Windows]
+
OCaml拥有的语言特性:
 +
*垃圾回收(garbage collection)
 +
*首类函数(first-class functions)可以像常规的值一样传递
 +
*静态类型检查(static type-checking)
 +
*参数化多态(parametric polymorphism)允许构造抽象涵盖不同数据类型,类似 [[C Sharp|C#]] 泛型和 [[C++]] 模板特性
 +
*支持不可变编程(immutable programming)
 +
*自动类型推断(automaticc type inference)
 +
*通过[https://v2.ocaml.org/manual/gadts-tutorial.html 通用代数数学类型(Generalized algebraic datatypes)GADTs] 和模式匹配(pattern matching)定义和管理复杂数据结构
  
 
==指南==
 
==指南==
 
[https://ocamlverse.github.io/ OCamlverse] Documenting everything about OCaml
 
[https://ocamlverse.github.io/ OCamlverse] Documenting everything about OCaml
 +
 +
Windows
 +
[https://protz.github.io/ocaml-installer/ OCaml on Windows]
  
 
完成第一个OCaml程序,Hello World!,创建test.ml文件,包含:  
 
完成第一个OCaml程序,Hello World!,创建test.ml文件,包含:  
第55行: 第65行:
 
==项目==
 
==项目==
 
[https://github.com/rizo/awesome-ocaml Awesome OCaml] [[image:awesome.png]]
 
[https://github.com/rizo/awesome-ocaml Awesome OCaml] [[image:awesome.png]]
 +
[[文件:FStarLang-logo.png|right|FStarLang]]
 +
*[https://github.com/ocaml/ocaml OCaml @ GitHub]
 
*[https://ocamlverse.github.io/content/ecosystem.html OCaml ecosystem] [https://ocamlverse.github.io/content/compilers.html Compilers, Typecheckers, and Parsers] [https://ocamlverse.github.io/content/security.html Security and Cryptography] [https://ocamlverse.github.io/content/static_analysis.html Static Analysis] [https://ocamlverse.github.io/content/testing.html Testing] [https://ocamlverse.github.io/content/software_verification.html Formal Software Verification] [https://ocamlverse.github.io/content/protocols.html Protocols]
 
*[https://ocamlverse.github.io/content/ecosystem.html OCaml ecosystem] [https://ocamlverse.github.io/content/compilers.html Compilers, Typecheckers, and Parsers] [https://ocamlverse.github.io/content/security.html Security and Cryptography] [https://ocamlverse.github.io/content/static_analysis.html Static Analysis] [https://ocamlverse.github.io/content/testing.html Testing] [https://ocamlverse.github.io/content/software_verification.html Formal Software Verification] [https://ocamlverse.github.io/content/protocols.html Protocols]
 
*[https://forge.ocamlcore.org/ OCaml Forge] Deprecating the Forge in 2017
 
*[https://forge.ocamlcore.org/ OCaml Forge] Deprecating the Forge in 2017
 
*[https://github.com/OCamlPro OCamlPro]
 
*[https://github.com/OCamlPro OCamlPro]
 
*[https://github.com/ocamllabs/ OCaml Labs]
 
*[https://github.com/ocamllabs/ OCaml Labs]
 +
*[[F*]] A Proof-oriented Programming Language
 +
*[https://github.com/jrh13/hol-light/ The HOL Light theorem prover]
 
*[https://dune.build/ Dune] is a build system for OCaml projects with support for [[Reason]] and [[Coq]]
 
*[https://dune.build/ Dune] is a build system for OCaml projects with support for [[Reason]] and [[Coq]]
 
*[https://github.com/ocsigen Ocsigen] Multi-tier programming for Web and mobile apps
 
*[https://github.com/ocsigen Ocsigen] Multi-tier programming for Web and mobile apps
第93行: 第107行:
 
*[https://github.com/facebook/infer Infer] is a static analysis tool for Java, Objective-C and C, written in OCaml.
 
*[https://github.com/facebook/infer Infer] is a static analysis tool for Java, Objective-C and C, written in OCaml.
 
*[https://github.com/facebook/pfff pfff] Tools for code analysis, visualizations, or style-preserving source transformation.
 
*[https://github.com/facebook/pfff pfff] Tools for code analysis, visualizations, or style-preserving source transformation.
 
==课程==
 
*[https://www.cs.cornell.edu/courses/cs3110/2014sp/lecture_notes.php CS 3110 Spring 2014 :: Data Structures and Functional Programming]
 
  
 
==文档==
 
==文档==
第114行: 第125行:
 
*[https://github.com/ocamllabs/compiler-hacking/wiki/Compiler-or-Language-projects-to-work-on Compiler or Language projects to work on]
 
*[https://github.com/ocamllabs/compiler-hacking/wiki/Compiler-or-Language-projects-to-work-on Compiler or Language projects to work on]
 
*[https://www.zhihu.com/people/hongbo_zhang 张宏波] 前[https://github.com/ocaml OCaml编译器]核心作者, [https://github.com/bloomberg/bucklescript BuckleScript] 作者。
 
*[https://www.zhihu.com/people/hongbo_zhang 张宏波] 前[https://github.com/ocaml OCaml编译器]核心作者, [https://github.com/bloomberg/bucklescript BuckleScript] 作者。
 +
 +
==课程==
 +
*[https://www.cs.cornell.edu/courses/cs3110/2014sp/lecture_notes.php CS 3110 Spring 2014 :: Data Structures and Functional Programming]
  
 
==用户==
 
==用户==

2022年10月19日 (三) 02:33的最后版本

Wikipedia-35x35.png 您可以在Wikipedia上了解到此条目的英文信息 OCaml Thanks, Wikipedia.

OCaml

OCaml-Logo.png

目录

[编辑] 简介

OCaml,最早称为 Objective Caml,是 Caml 编程语言的主要实现,由 Xavier Leroy,Jérôme Vouillon,Damien Doligez,Didier Rémy 及其他人于1996年创立,OCaml 是开放源代码项目(LGPLv2.1)。

OCaml 一般用于编译器、程序分析、金融交易、虚拟机等方面。它是 Jane Street 的核心语言,重点是用它写实时交易系统会很赚钱。

F#,Microsoft .NET平台上 OCaml 风格的编程语言。

ML 家族的两个主要的方言是 Standard ML 和 OCaml。

[编辑] 功能

OCaml拥有的语言特性:

  • 垃圾回收(garbage collection)
  • 首类函数(first-class functions)可以像常规的值一样传递
  • 静态类型检查(static type-checking)
  • 参数化多态(parametric polymorphism)允许构造抽象涵盖不同数据类型,类似 C# 泛型和 C++ 模板特性
  • 支持不可变编程(immutable programming)
  • 自动类型推断(automaticc type inference)
  • 通过通用代数数学类型(Generalized algebraic datatypes)GADTs 和模式匹配(pattern matching)定义和管理复杂数据结构

[编辑] 指南

OCamlverse Documenting everything about OCaml

Windows OCaml on Windows

完成第一个OCaml程序,Hello World!,创建test.ml文件,包含:

let _=print_endline "hello world!" 

编译 test.ml

ocamlc test.ml -o test  // Byte-code编译
或 ocamlopt test.ml -o test // Native-code编译
 ./test

REPL

 $ ocmal 或 $ utop // eval $(opam config env)
 utop # let () = print_endline "Hello OCaml World!";;
 Hello OCaml World!  

类型

 utop # (1, "str1", 2.);; // 元组tuple
- : int * string * float = (1, "str1", 2.)     
 utop # [1; 2; 3];; // 列表list
- : int list = [1; 2; 3]  
 utop # [|1; 2; 3|];; 数组array
- : int array = [|1; 2; 3|]   
 utop # type vec2 = { x : float; y : float };; //记录record
type vec2 = { x : float; y : float; }

[编辑] 常见问题

Error: Unbound module Core

vim ~/.ocamlinit 加入以下内容,并重新运行utop

#use "topfind"
#camlp4o
#thread
#require "core.top"
#require "core.syntax"

-bash: ocamlfind: command not found

eval $(opam config env)

[编辑] 项目

Awesome OCaml Awesome.png

FStarLang

Jane Street 开源的 Ocaml 项目

Facebook 开源的 OCaml 项目

  • Hack is a programming language for HHVM
  • flow Adds static typing to JavaScript to improve developer productivity and code quality.
  • Reason: Build Systems Rapidly
  • Infer is a static analysis tool for Java, Objective-C and C, written in OCaml.
  • pfff Tools for code analysis, visualizations, or style-preserving source transformation.

[编辑] 文档

[编辑] 书籍

[编辑] 开发

[编辑] 课程

[编辑] 用户

更多用户成功故事

[编辑] 图集

[编辑] 链接

分享您的观点
个人工具
名字空间

变换
操作
导航
工具箱