hydra-kernel-0.18.1: hydra-kernel-json/hydra/core/lib/functions.json
{
"name": "hydra.core.lib.functions",
"metadata": {
"description": "Primitives in the hydra.core.lib.functions module.",
"comments": [
"Function combinators: the identity/compose/const/flip basis. These primitives manipulate functions themselves, independently of any particular data type."],
"seeAlso": [],
"provisions": []},
"dependencies": [{"module": "hydra.core.model"}, {"module": "hydra.core.packaging"}, {"module": "hydra.core.typing"}],
"definitions": [
{
"primitive": {
"name": "hydra.core.lib.functions.absurd",
"metadata": {
"description": "Eliminate a value of the uninhabited void type, producing any type.",
"comments": [
"absurd(v) is the unique function from void to any type t1; since void has no inhabitants, this function can never actually be applied in a well-typed program.",
"Its purpose is to discharge an impossible branch in otherwise-total code, such as the left case of an either<void, a> that can never occur.",
"The eliminator dual to the (nonexistent) introducer for void.",
"Total, vacuously: there is no well-typed argument on which absurd could be called. Corresponds to Haskell's Data.Void.absurd :: Void -> a."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.17.6"},
"provisions": []},
"signature": {
"typeParameters": [{"name": "t1", "constraints": []}],
"parameters": [
{
"name": "v",
"description": "a value of the void type; unreachable in any well-typed program",
"type": "void",
"isLazy": false}],
"result": {"type": {"variable": "t1"}}},
"isPure": true,
"isTotal": true}},
{
"primitive": {
"name": "hydra.core.lib.functions.compose",
"metadata": {
"description": "Compose two functions.",
"comments": [
"compose(g, f, x) = g(f(x)); this defining equation is the specification.",
"The outer function comes first: f is applied to x, and g is applied to the result.",
"This is ordinary function composition, distinct from the Kleisli compose primitives of the monad modules.",
"Total. Corresponds to Haskell's (.) :: (b -> c) -> (a -> b) -> a -> c."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.17.6"},
"provisions": []},
"signature": {
"typeParameters": [{"name": "t1", "constraints": []}, {"name": "t2", "constraints": []}, {"name": "t3", "constraints": []}],
"parameters": [
{
"name": "g",
"description": "the outer function, applied to the result of f",
"type": {"function": {"domain": {"variable": "t2"}, "codomain": {"variable": "t3"}}},
"isLazy": false},
{
"name": "f",
"description": "the inner function, applied to x first",
"type": {"function": {"domain": {"variable": "t1"}, "codomain": {"variable": "t2"}}},
"isLazy": false},
{"name": "x", "description": "the argument to which f is applied", "type": {"variable": "t1"}, "isLazy": false}],
"result": {"type": {"variable": "t3"}}},
"isPure": true,
"isTotal": true,
"defaultImplementation": {
"lambda": {
"parameter": "g",
"body": {
"lambda": {
"parameter": "f",
"body": {
"lambda": {
"parameter": "x",
"body": {
"application": {
"function": {"variable": "g"},
"argument": {"application": {"function": {"variable": "f"}, "argument": {"variable": "x"}}}}}}}}}}}}},
{
"primitive": {
"name": "hydra.core.lib.functions.const",
"metadata": {
"description": "Return the first argument, ignoring the second.",
"comments": [
"const(x, y) = x; this defining equation is the specification.",
"Partially applied, const(x) is the constant function which returns x on every input.",
"Total. Corresponds to Haskell's const :: a -> b -> a."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.17.6"},
"provisions": [
{
"name": "hydra.core.lib.functions.const.returnsFirstArgumentIgnoringSecond",
"kind": "requirement",
"statement": "const returns its first argument unchanged and ignores its second argument entirely, regardless of the second argument's type or value."}]},
"signature": {
"typeParameters": [{"name": "t1", "constraints": []}, {"name": "t2", "constraints": []}],
"parameters": [
{"name": "x", "description": "the value to return", "type": {"variable": "t1"}, "isLazy": false},
{"name": "y", "description": "the ignored second argument", "type": {"variable": "t2"}, "isLazy": false}],
"result": {"type": {"variable": "t1"}}},
"isPure": true,
"isTotal": true,
"defaultImplementation": {"lambda": {"parameter": "x", "body": {"lambda": {"parameter": "y", "body": {"variable": "x"}}}}}}},
{
"primitive": {
"name": "hydra.core.lib.functions.flip",
"metadata": {
"description": "Swap the argument order of a binary function.",
"comments": [
"flip(f, x, y) = f(y, x); this defining equation is the specification.",
"Total. Corresponds to Haskell's flip :: (a -> b -> c) -> b -> a -> c."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.17.6"},
"provisions": [
{
"name": "hydra.core.lib.functions.flip.swapsArgumentOrder",
"kind": "requirement",
"statement": "flip(f, x, y) applies f with its two arguments in reversed order, i.e. flip(f, x, y) = f(y, x)."}]},
"signature": {
"typeParameters": [{"name": "t1", "constraints": []}, {"name": "t2", "constraints": []}, {"name": "t3", "constraints": []}],
"parameters": [
{
"name": "f",
"description": "the binary function whose argument order is swapped",
"type": {
"function": {"domain": {"variable": "t1"}, "codomain": {"function": {"domain": {"variable": "t2"}, "codomain": {"variable": "t3"}}}}},
"isLazy": false},
{"name": "x", "description": "the argument passed as f's second argument", "type": {"variable": "t2"}, "isLazy": false},
{"name": "y", "description": "the argument passed as f's first argument", "type": {"variable": "t1"}, "isLazy": false}],
"result": {"type": {"variable": "t3"}}},
"isPure": true,
"isTotal": true,
"defaultImplementation": {
"lambda": {
"parameter": "f",
"body": {
"lambda": {
"parameter": "x",
"body": {
"lambda": {
"parameter": "y",
"body": {
"application": {
"function": {"application": {"function": {"variable": "f"}, "argument": {"variable": "y"}}},
"argument": {"variable": "x"}}}}}}}}}}},
{
"primitive": {
"name": "hydra.core.lib.functions.identity",
"metadata": {
"description": "Return the argument unchanged.",
"comments": [
"identity(x) = x; this defining equation is the specification. The polymorphic identity function.",
"identity is the unit of compose: compose(identity, f) and compose(f, identity) are both f.",
"Total. Corresponds to Haskell's id :: a -> a.",
"Moved from hydra.lib.equality.identity."],
"seeAlso": [],
"lifecycle": {"availableSince": "0.17.6"},
"provisions": [
{
"name": "hydra.core.lib.functions.identity.returnsArgumentUnchanged",
"kind": "requirement",
"statement": "identity returns its argument completely unchanged, for any value."}]},
"signature": {
"typeParameters": [{"name": "t1", "constraints": []}],
"parameters": [{"name": "x", "description": "the value to return unchanged", "type": {"variable": "t1"}, "isLazy": false}],
"result": {"type": {"variable": "t1"}}},
"isPure": true,
"isTotal": true,
"defaultImplementation": {"lambda": {"parameter": "x", "body": {"variable": "x"}}}}}]}