tchou / stt Goto Github PK
View Code? Open in Web Editor NEWSet Theoretic Types
Set Theoretic Types
Parsing the type
type t1 = [ (X, Y) ]
where X = [ Int; Y* ]
and Y = X | `nil
type t2 = [ X; X ]
where X = [ t1*; Y ]
and Y = X | [ Z*; Bool ] | `nil
and Z = Int | X | `nil
gives the error
Fatal error: exception File "core/typ.ml", line 244, characters 2-8: Assertion failed
which is, for me, in the function
let descr n =
assert (n.id >= 0);
n.descr
Parsing the type
type t ('a, 'b) = [ X*; Y; X ]
where X = 'a | (Y & Z)
and Y = ('a, 'b) | `nil
and Z = [ 'a; 'b; X* ]
generates a very huge type when applying a substitution in order to compare it to its pretty-printed type (re-parsed)
This is the function doing the variable subsitution in order to do the comparison
open Stt
let alpha_renaming (t : Typ.t)
(t' : Typ.t) =
let vp, vn = Typ.vars t in
let v = Var.Set.union vp vn in
let var_map = Var.Set.fold (
fun v acc -> (v.Var.name, v) :: acc
) v []
in
let vp', vn' = Typ.vars t' in
let v' = Var.Set.union vp' vn' in
let subst = Var.Set.fold (
fun v acc ->
let n_var =
match List.assoc_opt v.Var.name var_map with
| Some n_var -> n_var
| None -> v
in
Subst.add v (Typ.var n_var) acc
) v' @@ Subst.of_list []
in
Subst.apply subst t'
It takes a lot of time while during
Stt.Typ.equiv t t'
where t
is the original type, and t'
the pretty-printed type
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.