stedolan / mlsub Goto Github PK
View Code? Open in Web Editor NEWPrototype type inference engine
Prototype type inference engine
Are sum types supported? If so, would it be possible to document the syntax used in the demo?
What happened to 'fun' and how do I use this thing ?
It might be an idea to update the README.
$ make
ocamlbuild -no-hygiene -r -cflag -bin-annot -cflag -g -lflag -g -pkg menhirLib -pkg str -use-menhir -yaccflag --explain -yaccflag --table main.byte
+ ocamlc.opt -c -bin-annot -g -I /home/aaron/.opam/default/lib/menhirLib -I /usr/lib/ocaml -o location.cmo location.ml
File "location.ml", line 47, characters 15-38:
47 | source fname (slurp (open_in fname))
^^^^^^^^^^^^^^^^^^^^^^^
Error: This expression has type bytes but an expression was expected of type
string
Command exited with code 2.
Compilation unsuccessful after building 8 targets (7 cached) in 00:00:00.
make: *** [Makefile:3: all] Error 10
(fun f -> (fun x -> f (fun v -> (x x) v)) (fun x -> f (fun v -> (x x) v)))
gives
((((a & a) -> (b | b)) -> ((a -> b) & c)) -> c)
instead of (((v1 -> v0) -> ((v1 -> v0) & v2)) -> v2)
(fun f -> (fun x -> f (fun v -> (x x) v)) (fun x -> f (fun v -> (x x) v))) (fun f -> fun x -> f)
gives
((Top) -> ((Top) -> ((Top) -> (rec b = ((Top) -> (rec a = ((Top) -> (a | b)) | b)) | rec d = ((Top) -> (rec c = ((Top) -> (c | d)) | d))))))
instead of (Top -> rec v0 = (Top -> v0))
mborch@wavel:~/co/mlsub$ make all
ocamlbuild -no-hygiene -r -cflag -bin-annot -cflag -g -lflag -g -pkg menhirLib -pkg str -use-menhir -yaccflag --explain main.byte
+ /Users/mborch/.opam/4.02.3/bin/ocamlc.opt -c -bin-annot -g -I /Users/mborch/.opam/4.02.3/lib/menhirLib -I /Users/mborch/.opam/4.02.3/lib/ocaml -o camlgen.cmo camlgen.ml
File "camlgen.ml", line 31, characters 16-1095:
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
(_, None)
+ /Users/mborch/.opam/4.02.3/bin/ocamlc.opt -c -bin-annot -g -I /Users/mborch/.opam/4.02.3/lib/menhirLib -I /Users/mborch/.opam/4.02.3/lib/ocaml -o source.cmo source.ml
File "source.ml", line 17, characters 11-30:
Error: Unbound module P.MenhirInterpreter
Command exited with code 2.
Compilation unsuccessful after building 28 targets (0 cached) in 00:00:00.
make: *** [all] Error 10
Building build-js
also fails:
mborch@wavel:~/co/mlsub$ make build-js
ocamlbuild -r -build-dir _build.js -use-ocamlfind -pkg menhirLib -use-menhir \
-package js_of_ocaml -package js_of_ocaml.syntax \
-syntax camlp4o webpage.byte
+ ocamlfind ocamlc -c -syntax camlp4o -package js_of_ocaml.syntax -package js_of_ocaml -package menhirLib -o webpage.cmo webpage.ml
File "webpage.ml", line 26, characters 16-30:
Error: Unbound value Parser.modlist
Command exited with code 2.
Compilation unsuccessful after building 25 targets (24 cached) in 00:00:00.
make: *** [build-js] Error 10
what's the license for the provided mlsub typechecker code? MIT?
Is there a description on why mlsub chooses {x: T1|T2, y: T3|T4} over {x:T1,y:T3}|{x:T2,y:T4} when computing a type union of {x:T1,y:T3} and {x:T2,y:T4}?
I understand that both typings are technically correct but want to know whether it is possible to steer the computation so it would produce the second option (union of records instead of record of unions)
Edit: more general question is, how does one encode a different options of traversing the subtyping lattice when there's multiple paths between types?
How do I build this on Ubuntu / Ubuntu WSL2 ?
$ sudo apt install ocaml
$ sudo apt install opam
$ opam install ocamlfind
$ opam install menhirLib
$ make
ocamlbuild -no-hygiene -r -cflag -bin-annot -cflag -g -lflag -g -pkg menhirLib -pkg str -use-menhir -yaccflag --explain -yaccflag --table main.byte
ocamlfind: Package `menhirLib' not found
Cannot run Ocamlfind.
make: *** [Makefile:3: all] Error 2
$ opam install menhirLib
[NOTE] Package menhirLib is already installed (current version is 20200624).
In the demo, I tried let rec x = {f1=x}
and got x : ({f1 : rec a = ({f1 : a})})
. This seems correct, but wouldn't x : rec a = {f1 : a}
be simpler?
I also tried let rec x = {f1=x;f2=x;f3=x;f4=x;f5=x;f6=x;f7=x}
and got a huge type expression, apparently exponential in the number of fields. I think this is just x : rec a = {f1 : a, f2 : a, f3 : a, f4 : a, f5 : a, f6 : a, f7 : a}
?
I have found the https://github.com/stedolan/mlsub/tree/pt branch, but cannot find jbuild or jbuilder-ify anywhere on the web.
I will do a pull request with a docker file over the weekend.
Getting the following :-
File "camlgen.ml", lines 31-61, characters 16-28:
31 | ................(loc, Some exp) = match exp with
32 | | Var v -> CVar v
33 | | Lambda (args, body) ->
34 | assert false
35 | (* CLambda ([args], lower g body) *)
...
58 | | GetField (obj, field) ->
59 | withtmp (lower g obj) (fun obj ->
60 | CApp (CRaw "get_field", [obj; CInt (Symbol.hash field)]))
61 | | _ -> CRaw "assert false"
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
(Loc (_, _, _), None)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.