hydra-kernel-0.18.1: hydra-kernel-json/hydra/core/lib/logic.json
{
"name": "hydra.core.lib.logic",
"metadata": {"description": "Primitives in the hydra.core.lib.logic module.", "comments": [], "seeAlso": [], "provisions": []},
"dependencies": [{"module": "hydra.core.model"}, {"module": "hydra.core.packaging"}, {"module": "hydra.core.typing"}],
"definitions": [
{
"primitive": {
"name": "hydra.core.lib.logic.and",
"metadata": {
"description": "Compute the logical AND of two boolean values.",
"comments": [
"and(p, q) returns true iff both p and q are true.",
"The second operand is not necessarily evaluated: and is short-circuiting, and returns false as soon as the first operand is false without evaluating the second.",
"Total. Corresponds to Haskell's (&&) :: Bool -> Bool -> Bool."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.15"},
"provisions": [
{
"name": "hydra.core.lib.logic.and.trueOnlyWhenBothTrue",
"kind": "requirement",
"statement": "and(p, q) returns true exactly when both p and q are true; any false operand makes the result false."}]},
"signature": {
"typeParameters": [],
"parameters": [
{"name": "p", "description": "the first boolean operand", "type": {"literal": "boolean"}, "isLazy": false},
{"name": "q", "description": "the second boolean operand", "type": {"literal": "boolean"}, "isLazy": true}],
"result": {"type": {"literal": "boolean"}}},
"isPure": true,
"isTotal": true,
"defaultImplementation": {
"lambda": {
"parameter": "a",
"body": {
"lambda": {
"parameter": "b",
"body": {
"application": {
"function": {
"application": {
"function": {"application": {"function": {"variable": "hydra.core.lib.logic.ifElse"}, "argument": {"variable": "a"}}},
"argument": {"variable": "b"}}},
"argument": {"literal": {"boolean": false}}}}}}}}}},
{
"primitive": {
"name": "hydra.core.lib.logic.ifElse",
"metadata": {
"description": "Compute a conditional expression.",
"comments": [
"ifElse(p, t, f) returns t if p is true, or f if p is false.",
"The unselected branch is not necessarily evaluated; ifElse is the standard way to express short-circuiting boolean logic and branching in Hydra.",
"Total. Corresponds to Haskell's if/then/else."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.15"},
"provisions": [
{
"name": "hydra.core.lib.logic.ifElse.selectsBranchByCondition",
"kind": "requirement",
"statement": "ifElse(p, t, f) returns t when p is true and f when p is false, for any value type of t/f including booleans, integers, and strings -- the then/else branches may be of any (matching) type."}]},
"signature": {
"typeParameters": [{"name": "x", "constraints": []}],
"parameters": [
{"name": "p", "description": "the boolean condition", "type": {"literal": "boolean"}, "isLazy": false},
{"name": "t", "description": "the value returned when p is true", "type": {"variable": "x"}, "isLazy": true},
{"name": "f", "description": "the value returned when p is false", "type": {"variable": "x"}, "isLazy": true}],
"result": {"type": {"variable": "x"}}},
"isPure": true,
"isTotal": true}},
{
"primitive": {
"name": "hydra.core.lib.logic.not",
"metadata": {
"description": "Compute the logical NOT of a boolean value.",
"comments": ["not(p) returns false if p is true, or true if p is false.", "Total. Corresponds to Haskell's not :: Bool -> Bool."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.15"},
"provisions": [
{
"name": "hydra.core.lib.logic.not.negatesBoolean",
"kind": "requirement",
"statement": "not(p) returns false when p is true and true when p is false."}]},
"signature": {
"typeParameters": [],
"parameters": [{"name": "p", "description": "the boolean value to negate", "type": {"literal": "boolean"}, "isLazy": false}],
"result": {"type": {"literal": "boolean"}}},
"isPure": true,
"isTotal": true,
"defaultImplementation": {
"lambda": {
"parameter": "a",
"body": {
"application": {
"function": {
"application": {
"function": {"application": {"function": {"variable": "hydra.core.lib.logic.ifElse"}, "argument": {"variable": "a"}}},
"argument": {"literal": {"boolean": false}}}},
"argument": {"literal": {"boolean": true}}}}}}}},
{
"primitive": {
"name": "hydra.core.lib.logic.or",
"metadata": {
"description": "Compute the logical OR of two boolean values.",
"comments": [
"or(p, q) returns true iff at least one of p and q is true.",
"The second operand is not necessarily evaluated: or is short-circuiting, and returns true as soon as the first operand is true without evaluating the second.",
"Total. Corresponds to Haskell's (||) :: Bool -> Bool -> Bool."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.15"},
"provisions": [
{
"name": "hydra.core.lib.logic.or.trueWhenEitherTrue",
"kind": "requirement",
"statement": "or(p, q) returns true when at least one of p and q is true; it returns false only when both are false."}]},
"signature": {
"typeParameters": [],
"parameters": [
{"name": "p", "description": "the first boolean operand", "type": {"literal": "boolean"}, "isLazy": false},
{"name": "q", "description": "the second boolean operand", "type": {"literal": "boolean"}, "isLazy": true}],
"result": {"type": {"literal": "boolean"}}},
"isPure": true,
"isTotal": true,
"defaultImplementation": {
"lambda": {
"parameter": "a",
"body": {
"lambda": {
"parameter": "b",
"body": {
"application": {
"function": {
"application": {
"function": {"application": {"function": {"variable": "hydra.core.lib.logic.ifElse"}, "argument": {"variable": "a"}}},
"argument": {"literal": {"boolean": true}}}},
"argument": {"variable": "b"}}}}}}}}}]}