ocaml

Docker运行之com.docker.supervisor failed to start Exit code 1 问题之解决

穿精又带淫゛_ 提交于 2019-11-29 02:29:48
Docker是一个非常跨时代的工具,是在继虚拟化之后的新一个好用易用的工具,可以极大提升开发和部署的效率。本文将解决一个在Mac上部署Docker之时碰到的问题。 环境介绍 操作系统: MacOS 10.13.2 (17C205) Docker 版本: 17.12.0-ce-mac47 Dock version Command: docker version Client: Version: 17.12 .0 -ce API version : 1.35 Go version : go1 .9 .2 Git commit: c97c6d6 Built: Wed Dec 27 20 : 03 : 51 2017 OS/Arch: darwin/amd64 Cannot connect to the Docker daemon at unix: ///var/run/docker.sock. Is the docker daemon running? 问题表现 启动Docker,会弹出错误提示对话框: 错误信息为: Fatal Error com.docker.supervisor failed to start Exit code 1. 然后docker就启动失败了,整个docker无法正常启动…. 这个docker可是我刚刚从docker的官方网站下载的最新stable版本

Parsing grammars using OCaml

∥☆過路亽.° 提交于 2019-11-29 01:30:40
问题 I have a task to write a (toy) parser for a (toy) grammar using OCaml and not sure how to start (and proceed with) this problem. Here's a sample Awk grammar: type ('nonterm, 'term) symbol = N of 'nonterm | T of 'term;; type awksub_nonterminals = Expr | Term | Lvalue | Incrop | Binop | Num;; let awksub_grammar = (Expr, function | Expr -> [[N Term; N Binop; N Expr]; [N Term]] | Term -> [[N Num]; [N Lvalue]; [N Incrop; N Lvalue]; [N Lvalue; N Incrop]; [T"("; N Expr; T")"]] | Lvalue -> [[T"$"; N

What are row types? Are they algebraic data types?

有些话、适合烂在心里 提交于 2019-11-29 01:17:59
I often hear that F# lacks support for OCaml row types, that makes the language more powerful than F#. What are they? Are they algebraic data types, such as sum types (discriminated unions) or product types (tuples, records)? And is it possible to write row types in other dialects, such as F#? First of all, we need to fix the terminology. There is no such thing as "row type" † , at least in type theory and especially in the type system of OCaml. There exists "row polymorphism" and we will discuss it below 0 . Row polymorphism is a form of polymorphism. OCaml provides two kinds of polymorphism

What is the most efficient implementation of arrays with functional updates?

一个人想着一个人 提交于 2019-11-29 01:03:24
问题 I need an array-like data structure with the fastest possible functional update. I've seen a few different implementation of flexible arrays that provide me with this property (Braun, Random Access Lists) but I'm wondering if there is an implementation that is specifically optimized for the case when we are not interested in append or prepend - just updates. 回答1: Jean-Cristophe Filliâtre has a very nice implementation of persistent arrays, that is described in the paper linked at the same

How do you compute the difference between successive elements of a list of unknown size, functionally?

空扰寡人 提交于 2019-11-28 22:43:00
In a programming language that is purely functional (like Haskell) or where you are only using it in a functional way (eg clojure); suppose you have a list/seq/enumerable (of unknown size) of integers and you want to produce a new list/seq/enumerable that contains the differences between successive items, how would you do it? What I did previously in C# was to fold over the list and keep a state object as the aggregating value which recorded the 'previous' item so that you could do a diff on it from the current item. The the result list also had to go into the state object (which is a problem

Redundancy in OCaml type declaration (ml/mli)

放肆的年华 提交于 2019-11-28 22:13:01
问题 I'm trying to understand a specific thing about ocaml modules and their compilation: am I forced to redeclare types already declared in a .mli inside the specific .ml implementations? Just to give an example: (* foo.mli *) type foobar = Bool of bool | Float of float | Int of int (* foo.ml *) type baz = foobar option This, according to my normal way of thinking about interfaces/implementations, should be ok but it says Error: Unbound type constructor foobar while trying to compile with ocamlc

OCaml internals: Exceptions

点点圈 提交于 2019-11-28 18:46:17
I'm curious to know how exceptions are dealt with in OCaml runtime to make them so lightweight. Do they use setjmp/longjmp or do they return a special value in each function, and propagate it? It seems to me that longjmp would put a little strain on the system, but only when an exception is raised, while checking for each function return value would need to check for every and each value after calling a function, which seems to me would put a lot of checks and jumps, and it seems it would perform worst. By looking at how OCaml interfaces with C ( http://caml.inria.fr/pub/docs/manual-ocaml

OCaml: Match expression inside another one?

自闭症网瘾萝莉.ら 提交于 2019-11-28 18:25:50
问题 I'm currently working on a small project with OCaml; a simple mathematical expression simplifier. I'm supposed to find certain patterns inside an expression, and simplify them so the number of parenthesis inside the expression decreases. So far I've been able to implement most rules except two, for which I've decided to create a recursive, pattern-matching "filter" function. The two rules I need to implement are: -Turn all expressions of the form a - (b + c) or similar into a - b - c -Turn

Algorithm for type checking ML-like pattern matching?

怎甘沉沦 提交于 2019-11-28 17:28:48
How do you determine whether a given pattern is "good", specifically whether it is exhaustive and non-overlapping, for ML-style programming languages? Suppose you have patterns like: match lst with x :: y :: [] -> ... [] -> ... or: match lst with x :: xs -> ... x :: [] -> ... [] -> ... A good type checker would warn that the first is not exhaustive and the second is overlapping. How would the type checker make those kinds of decisions in general, for arbitrary data types? pigworker Here's a sketch of an algorithm. It's also the basis of Lennart Augustsson's celebrated technique for compiling

Variants or Polymorphic variants?

女生的网名这么多〃 提交于 2019-11-28 16:27:36
问题 I noticed that, among OCaml programmers I know, some of them always use polymorphic variants (variants that are not declared, prefixed with a backquote), while other ones never use polymorphic variants, and prefer variants declared in types. Except for performance reasons (polymorphic variants are currently compiled less efficiently than simple variants), how do expert OCaml developers choose between them ? 回答1: My usage can be divided into the following 5 categories. 1. interface 2.