Skip to content

Experiments with Type module #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
280 changes: 241 additions & 39 deletions src/Core__Type.mjs
Original file line number Diff line number Diff line change
@@ -1,53 +1,255 @@
// Generated by ReScript, PLEASE EDIT WITH CARE

import * as Caml_option from "rescript/lib/es6/caml_option.js";

function isNull(i) {
return i === null;
}

function isNullOrUndefined(i) {
if (i === null) {
return true;
} else {
return i === undefined;
}
}

function isUndefined(i) {
return i === undefined;
}

function classify(value) {
var match = Object.prototype.toString.call(value);
switch (match) {
case "[object Boolean]" :
return {
TAG: /* Bool */0,
_0: value
};
case "[object AsyncFunction]" :
case "[object Function]" :
case "[object GeneratorFunction]" :
return {
TAG: /* Function */4,
_0: value
};
case "[object Null]" :
return /* Null */0;
case "[object Number]" :
return {
TAG: /* Number */2,
_0: value
};
case "[object String]" :
return {
TAG: /* String */1,
_0: value
};
case "[object Symbol]" :
return {
TAG: /* Symbol */5,
_0: value
};
case "[object Undefined]" :
return /* Undefined */1;
default:
var match = typeof value;
if (match === "symbol") {
return {
TAG: /* Symbol */5,
_0: value
};
} else if (match === "boolean") {
return {
TAG: /* Bool */1,
_0: value
};
} else if (match === "string") {
return {
TAG: /* String */4,
_0: value
};
} else if (match === "function") {
return {
TAG: /* Function */6,
_0: value
};
} else if (match === "object") {
if (value === null) {
return /* Null */1;
} else {
return {
TAG: /* Object */3,
TAG: /* Object */0,
_0: value
};
}
} else if (match === "undefined") {
return /* Undefined */0;
} else if (match === "number") {
return {
TAG: /* Number */2,
_0: value
};
} else {
return {
TAG: /* BigInt */3,
_0: value
};
}
}

function toObject(i) {
if (typeof i === "object") {
return Caml_option.some(i);
}

}

var Classify = {
classify: classify
};
function toBool(i) {
if (typeof i === "boolean") {
return i;
}

}

function toFloat(i) {
if (typeof i === "number") {
return i;
}

}

function toBigInt(i) {
if (typeof i === "bigint") {
return Caml_option.some(i);
}

}

function toString(i) {
if (typeof i === "string") {
return i;
}

}

function toSymbol(i) {
if (typeof i === "symbol") {
return Caml_option.some(i);
}

}

function toFunction(i) {
if (typeof i === "function") {
return Caml_option.some(i);
}

}

function getObject(o, n) {
if (isNullOrUndefined(o)) {
return ;
} else {
return toObject(o[n]);
}
}

function getObjectBySymbol(o, s) {
if (isNullOrUndefined(o)) {
return ;
} else {
return toObject(o[s]);
}
}

function getBool(o, n) {
if (isNullOrUndefined(o)) {
return ;
} else {
return toBool(o[n]);
}
}

function getBoolBySymbol(o, s) {
if (isNullOrUndefined(o)) {
return ;
} else {
return toBool(o[s]);
}
}

function getFloat(o, n) {
if (isNullOrUndefined(o)) {
return ;
} else {
return toFloat(o[n]);
}
}

function getFloatBySymbol(o, s) {
if (isNullOrUndefined(o)) {
return ;
} else {
return toFloat(o[s]);
}
}

function getBigInt(o, n) {
if (isNullOrUndefined(o)) {
return ;
} else {
return toBigInt(o[n]);
}
}

function getBigIntBySymbol(o, s) {
if (isNullOrUndefined(o)) {
return ;
} else {
return toBigInt(o[s]);
}
}

function getString(o, n) {
if (isNullOrUndefined(o)) {
return ;
} else {
return toString(o[n]);
}
}

function getStringBySymbol(o, s) {
if (isNullOrUndefined(o)) {
return ;
} else {
return toString(o[s]);
}
}

function getSymbol(o, n) {
if (isNullOrUndefined(o)) {
return ;
} else {
return toSymbol(o[n]);
}
}

function getSymbolBySymbol(o, s) {
if (isNullOrUndefined(o)) {
return ;
} else {
return toSymbol(o[s]);
}
}

function getFunction(o, n) {
if (isNullOrUndefined(o)) {
return ;
} else {
return toFunction(o[n]);
}
}

function getFunctionBySymbol(o, s) {
if (isNullOrUndefined(o)) {
return ;
} else {
return toFunction(o[s]);
}
}

export {
Classify ,
classify ,
isUndefined ,
isNull ,
isNullOrUndefined ,
toObject ,
toBool ,
toFloat ,
toBigInt ,
toString ,
toSymbol ,
toFunction ,
getObject ,
getObjectBySymbol ,
getBool ,
getBoolBySymbol ,
getFloat ,
getFloatBySymbol ,
getBigInt ,
getBigIntBySymbol ,
getString ,
getStringBySymbol ,
getSymbol ,
getSymbolBySymbol ,
getFunction ,
getFunctionBySymbol ,
}
/* No side effect */
Loading