OCaml: Why does renaming a type fail with “Their kinds differ”

I'm building an universal container for for pairs of a type witness and a value of the witnessed type. This I want to use for several different types, which gives me errors because the types are all named the same.

Best How To :

This is due to the fact that type aliases and type definitions do not behave in the same way in regard to destructive substitution. Here for example, with lexeme_conv an alias, the signature will change (since the record definition would stop being exposed), which is forbidden.

You can protect your current working directory with with some synchronization primitive, like Lwt_mutex. But there is some caveat here, suppose you have this chain: lock dir_guard >> chdir dir >> exec proc >> chdir dir' >> unlock dir_guard Which disallows changing the directory for the whole time the process...

How you pass annotations to your TAC is a very open question, but I'd agree that you probably want to do so. One approach to scoping is name erasure; as you resolve scopes, you replace each unique identifier with a unique "name" (or directly with a reference to the symbol...

Firstly, what happens if you have a module that imports another module? Do you put the module that is imported into a subdirectory of the directory containing the first module, or in another separate directory in the root? A module is just a file with Python code - you...

In order to use external library you still need to link. There're at least two different ways, either link using compiler, or link even more dynamically using dlopen. For the first method use the following command (as an initial approximation): ocamlbuild -pkg ctypes.foreign -lflags -cclib,-lRmath yourapp.native under premise that your...

Well, bin_prot is just a serialization protocol, and doesn't depend on whatever you're using for a transport layer. Basically, to serialize a value to string, you can use Binable.to_string function (or Binable.to_bigstring). It accepts a packed module. For example, to serialize a set of ints, do the following: let str...

Instead of accumulating the values on the way recursing to the end, you can collect the values on the way back up: let rem_from_right lst = let rec is_member n mlst = match mlst with | [] -> false | h::tl -> begin if h=n then true else is_member n...

You use them the same way you would in other code. Dim variableName As className Set variableName = New className variableName.someMethod Set variableName = Nothing I find Chip Pearson's web site to be very useful. Here are some links specific to your question: Classes in VBA Custom Collection Classes You...

It seems like you want to merge two objects. You can do this with Object.assign if available: Object.assign(Motorbike.prototype, config); See How can I merge properties of two JavaScript objects dynamically? for alternative ways....

In an expression the = operator in OCaml is a comparison operator that tests for equality. To assign to an array, use the <- operator. The compiler is complaining because your expression has type bool (i.e., the result of the comparison). The expression in a for should have type unit...

The problem is that use paths are absolute, not relative. When you say use A; what you are actually saying is "use the symbol A in the root module of this crate", which would be lib.rs. What you need to use is use super::A;, that or the full path: use...

You're exporting a function that when called returns another function which in turn will throw an ReferenceError saying that value is undefined which you can alleviate by defining value. return function() { func1(); func2(); return 1; //for example }; In order to run it you need to call it twice....

As pa_ounit readme says, run the executable that contains tests with inline-test-runner argument. Even without pa_ounit (when using plain OUnit), the file with tests is compiled and then executed. You should probably try OUnit itself before you start using the syntax extension so you can get the feel of the...

The = symbol is here to check an equality when not preceded by a let. If you want to change the value of one element of an array, you have to use <- instead. let test = fun x y u -> for i = 0 to (w-1) do for...

The system you cite, SWI-Prolog, is a system whose core is developed by a single developer. Such bold statements as those you quote are his very personal opinions. In the past, SWI did follow ISO standards for a certain period. Then, recently changed. If you want to read more about...

When you module first gets executed (e.g. when you script is first parsed), addAmount is assigned the return value of getAmount() which, when you don't pass in an argument, is undefined. Now when you return the object from the module and assign returnAmount to addAmount - you are setting returnAmount...

When you require() a module, it is evaluated once and cached so that subsequent require()s for the same module do not have to get loaded from disk and thus get the same exported object. So when you mutate exported properties, all references to that module will see the updated value.

Haha!,I get the answer from the linux kernel source code by myself;When you use the insmod,it will call the init_moudle,load_module,strndup_usr then memdup_usr function;the memdup_usr function will use kmalloc_track_caller to alloc memery from slab and then use the copy_from_usr to copy the module paragram into kernel;this mean the linux kernel module...

The convention is to declare constants in modules as variables written in upper-case (Python style guide: https://www.python.org/dev/peps/pep-0008/#global-variable-names). But there's no way to prevent someone else to re-declare such a variable -- thus ignoring conventions -- when importing a module. There are two ways of working around this when importing modules...

My best guess is that you are using the mpfun library, which defines a type mp_real exactly how you use it. Then, they overload the assignment operator to be able to convert types. This operator is not available at compile time which results in the error you get. Here is...

You need to blacklist the module. For debian systems see https://wiki.debian.org/KernelModuleBlacklisting. For redhat systems see https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Installation_Guide/rescuemode_drivers-blacklisting.html

First you should look for the file vcvarsall.bat in your system. If it does not exits I recommend you to install Microsoft Visual C++ Compiler for Python 2.7. This will create the vcvarsall.bat in "C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0" if you install it for all users. The problem...

float_of_string should be able to parse them: # float_of_string "0x1.199999999999Ap1";; - : float = 2.2 However as Alain Frisch noted on OCaml's bug tracker the support actually depends on the underlying libc and won't currently work on the MSVC ports....

I'm wondering if there's a workaround for this Yes. Use a tsconfig.json file : https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md With that you don't need reference comments....

Well, pip install should work for PyDev (it should automatically recognize the dependency)... I.e.: in your use case, the only folder that should be in the PYTHONPATH is D:\apps\Python34\lib\site-packages (and pip should install packages to that folder -- make sure you don't add extra folders for "D:\apps\Python34\lib\site-packages\django" nor anything else...

If the toplevel is already launched, you can dynamically load the library: # #load "nums.cma";; # Num.mult_num;; - : Num.num -> Num.num -> Num.num = <fun> Another possibility (which will work for all third party libraries and will manage paths and dependencies for you) is to use ocamlfind. For this,...

Since it is supposed to be used commonly among modules, use should create a file called constants inside your package and initialize the variable with file contents in it. As an afterthought, init file of package is also good candidate for such kind of data.

The Core library replaces the standard OCaml List module. When you open Core.Std you mask OCaml's standard List with Core's Core.Std.List module. The Core.Std.List.assoc function does not exist. If you aren't opening Core.Std in utop then you're most likely still working with OCaml's standard library List module. Core does provide...

You can follow this tutorial for the basics in creating a D7 module. https://www.drupal.org/node/1074360 As far as custom database tables I suggest taking a look at this module. https://www.drupal.org/project/eck Also take a look at this video for more info about 'ECK'. http://codekarate.com/daily-dose-of-drupal/drupal-7-entity-construction-kit...

Yes, you can define a record recursively with the rec keyword, roughly speaking as long as all the fields are guaranteed to not involve an arbitrary computation. The following works: type t = { name : string; help : string ; run : string list -> unit } let run...

You can write t.Unix.tm_yday $ ocaml OCaml version 4.02.1 # let f (t: Unix.tm) = t.tm_yday;; Warning 40: tm_yday was selected from type Unix.tm. It is not visible in the current scope, and will not be selected if the type becomes unknown. val f : Unix.tm -> int = <fun>...

#use is not emacs specific, and is not even OCaml language specific. It is a directive of a program called toplevel, or in a more common parlance an interpreter. So, your premises is wrong, that you can do this in Emacs. What concerning Eclipse (I suspect, that you're trying to...

You have two options: import math math.sqrt() will import the math module into its own namespace. This means that function names have to be prefixed with math. This is good practice because it avoids conflicts and won't overwrite a function that was already imported into the current namespace. Alternatively: from...

Your declaration says there is a module named random-string with a function named randomString within it... So your usage should be: console.log(randomString.randomString({ length: 10 })); console.log(randomString.randomString()); If the module does actually supply the function directly, you should adjust your definition to do the same: declare module "random-string" { function randomString(opts?:...

There is a better way to do it! You could make use of --save option of bower to have the dependencies. For example you could have done: bower install angular --dev --save So that, the bower.json file is automatically updated by the bower and you don't have to touch it!...

match and if has different semantics: match is parallel, if is strictly sequential. If you have expression: match expr with | A -> e1 | B -> e2 | C -> e3 | ... Then it may compare branches in any order. In the example, I provided, it may compile...

This is a partial answer, written for Scala but applicable to other languages. A bug is something happening which was not expected. Thus, to solve bugs, the language should allow to let the user write any expectations and interact with them (proof, synthesis, etc.). There are several ways to address...

You should use Str.search_forward instead. According to the ocaml docs: string_match r s start tests whether a substring of s that starts at position start matches the regular expression r. I am guessing this means it doesn't traverse through the entire string like search_forward does....

The gist of it is that this in the global scope, in a browser, is window. In other environments (mainly node.js), it's not window, but rather a different global object, but in many ways we care about it acts the same. Your code isn't working because you need to instantiate...

If you want to add custom field manually or to allow custom extensions within the framework or to change the behavior or data type of fields, then you need to do modification in custom Ext directory. You will found more details related to extension Sugar Doc And Example For...