Skip to content

Commit

Permalink
Add Bool module
Browse files Browse the repository at this point in the history
  • Loading branch information
fhammerschmidt committed Aug 27, 2024
1 parent 22642ea commit b054aac
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/Core__Bool.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Generated by ReScript, PLEASE EDIT WITH CARE


function fromStringExn(param) {
switch (param) {
case "false" :
return false;
case "true" :
return true;
default:
throw {
RE_EXN_ID: "Invalid_argument",
_1: "Bool.fromStringExn: value is neither \"true\" nor \"false\"",
Error: new Error()
};
}
}

function fromString(param) {
switch (param) {
case "false" :
return false;
case "true" :
return true;
default:
return ;
}
}

function xor(a, b) {
return a !== b;
}

function xnor(a, b) {
return a === b;
}

function nand(a, b) {
return !(a && b);
}

function nor(a, b) {
return !(a || b);
}

export {
fromStringExn ,
fromString ,
xnor ,
xor ,
nand ,
nor ,
}
/* No side effect */
34 changes: 34 additions & 0 deletions src/Core__Bool.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Core__Bool.res
external compare: (bool, bool) => Core__Ordering.t = "%compare"

external equal: (bool, bool) => bool = "%equal"

@send external toString: bool => string = "toString"

let fromStringExn = param =>
switch param {
| "true" => true
| "false" => false
| _ => raise(Invalid_argument(`Bool.fromStringExn: value is neither "true" nor "false"`))
}

let fromString = param =>
switch param {
| "true" => Some(true)
| "false" => Some(false)
| _ => None
}

external and_: (bool, bool) => bool = "%sequand"

external or: (bool, bool) => bool = "%sequor"

external not: bool => bool = "%boolnot"

let xor = (a, b) => a !== b

let xnor = (a, b) => !xor(a, b)

let nand = (a, b) => !and_(a, b)

let nor = (a, b) => !or(a, b)
23 changes: 23 additions & 0 deletions src/Core__Bool.resi
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
external compare: (bool, bool) => Core__Ordering.t = "%compare"

external equal: (bool, bool) => bool = "%equal"

@send external toString: bool => string = "toString"

let fromStringExn: string => bool

let fromString: string => option<bool>

external and_: (bool, bool) => bool = "%sequand"

external or: (bool, bool) => bool = "%sequor"

external not: bool => bool = "%boolnot"

let xnor: (bool, bool) => bool

let xor: (bool, bool) => bool

let nand: (bool, bool) => bool

let nor: (bool, bool) => bool

0 comments on commit b054aac

Please sign in to comment.