packages feed

hydra-kernel-0.18.1: hydra-kernel-json/hydra/core/lib/pairs.json

{
  "name": "hydra.core.lib.pairs",
  "metadata": {
    "description": "Primitives in the hydra.core.lib.pairs module.",
    "comments": [
      "Pairs: the two-component product type. This module provides the two projections, the bifunctor map, and the constructor."],
    "seeAlso": [],
    "provisions": []},
  "dependencies": [{"module": "hydra.core.model"}, {"module": "hydra.core.packaging"}, {"module": "hydra.core.typing"}],
  "definitions": [
    {
      "primitive": {
        "name": "hydra.core.lib.pairs.bimap",
        "metadata": {
          "description": "Map over both elements of a pair.",
          "comments": [
            "bimap(f, g, p) returns a new pair (f(first(p)), g(second(p))). The bifunctor map for pairs.",
            "Total. Corresponds to Haskell's Data.Bifunctor.bimap :: (a -> c) -> (b -> d) -> (a, b) -> (c, d)."],
          "seeAlso": [],
          "lifecycle": {"availableSince": "0.15"},
          "provisions": [
            {
              "name": "hydra.core.lib.pairs.bimap.mapsBothElementsIndependently",
              "kind": "requirement",
              "statement": "bimap applies the first function to the pair's first element and the second function to the pair's second element, producing a new pair of the two results, for any element and function types."}]},
        "signature": {
          "typeParameters": [
            {"name": "a", "constraints": []},
            {"name": "b", "constraints": []},
            {"name": "c", "constraints": []},
            {"name": "d", "constraints": []}],
          "parameters": [
            {
              "name": "f",
              "description": "the function applied to the first element",
              "type": {"function": {"domain": {"variable": "a"}, "codomain": {"variable": "c"}}},
              "isLazy": false},
            {
              "name": "g",
              "description": "the function applied to the second element",
              "type": {"function": {"domain": {"variable": "b"}, "codomain": {"variable": "d"}}},
              "isLazy": false},
            {
              "name": "p",
              "description": "the pair to map over",
              "type": {"pair": {"first": {"variable": "a"}, "second": {"variable": "b"}}},
              "isLazy": false}],
          "result": {"type": {"pair": {"first": {"variable": "c"}, "second": {"variable": "d"}}}}},
        "isPure": true,
        "isTotal": true,
        "defaultImplementation": {
          "lambda": {
            "parameter": "f",
            "body": {
              "lambda": {
                "parameter": "g",
                "body": {
                  "lambda": {
                    "parameter": "p",
                    "body": {
                      "pair": {
                        "first": {
                          "application": {
                            "function": {"variable": "f"},
                            "argument": {"application": {"function": {"variable": "hydra.core.lib.pairs.first"}, "argument": {"variable": "p"}}}}},
                        "second": {
                          "application": {
                            "function": {"variable": "g"},
                            "argument": {"application": {"function": {"variable": "hydra.core.lib.pairs.second"}, "argument": {"variable": "p"}}}}}}}}}}}}}}},
    {
      "primitive": {
        "name": "hydra.core.lib.pairs.first",
        "metadata": {
          "description": "Get the first element of a pair.",
          "comments": ["first(p) returns the first component of the pair p.", "Total. Corresponds to Haskell's fst :: (a, b) -> a."],
          "seeAlso": [],
          "lifecycle": {"availableSince": "0.15"},
          "provisions": [
            {
              "name": "hydra.core.lib.pairs.first.returnsFirstComponent",
              "kind": "requirement",
              "statement": "first returns the first component of the pair unchanged, for any element type and value."}]},
        "signature": {
          "typeParameters": [{"name": "a", "constraints": []}, {"name": "b", "constraints": []}],
          "parameters": [
            {
              "name": "p",
              "description": "the pair whose first element is returned",
              "type": {"pair": {"first": {"variable": "a"}, "second": {"variable": "b"}}},
              "isLazy": false}],
          "result": {"type": {"variable": "a"}}},
        "isPure": true,
        "isTotal": true}},
    {
      "primitive": {
        "name": "hydra.core.lib.pairs.pair",
        "metadata": {
          "description": "Construct a pair from two values.",
          "comments": [
            "pair(x, y) returns the pair (x, y).",
            "The type-free pair constructor, useful point-free (e.g. zipWith(pair, xs, ys)).",
            "Total. Corresponds to Haskell's (,) :: a -> b -> (a, b)."],
          "seeAlso": [],
          "lifecycle": {"availableSince": "0.17.6"},
          "provisions": [
            {
              "name": "hydra.core.lib.pairs.pair.constructsFromTwoValues",
              "kind": "requirement",
              "statement": "pair x y constructs the pair (x, y), preserving both components exactly as given, for any value."}]},
        "signature": {
          "typeParameters": [{"name": "a", "constraints": []}, {"name": "b", "constraints": []}],
          "parameters": [
            {"name": "x", "description": "the first element", "type": {"variable": "a"}, "isLazy": false},
            {"name": "y", "description": "the second element", "type": {"variable": "b"}, "isLazy": false}],
          "result": {"type": {"pair": {"first": {"variable": "a"}, "second": {"variable": "b"}}}}},
        "isPure": true,
        "isTotal": true}},
    {
      "primitive": {
        "name": "hydra.core.lib.pairs.second",
        "metadata": {
          "description": "Get the second element of a pair.",
          "comments": ["second(p) returns the second component of the pair p.", "Total. Corresponds to Haskell's snd :: (a, b) -> b."],
          "seeAlso": [],
          "lifecycle": {"availableSince": "0.15"},
          "provisions": [
            {
              "name": "hydra.core.lib.pairs.second.returnsSecondComponent",
              "kind": "requirement",
              "statement": "second returns the second component of the pair unchanged, for any element type and value."}]},
        "signature": {
          "typeParameters": [{"name": "a", "constraints": []}, {"name": "b", "constraints": []}],
          "parameters": [
            {
              "name": "p",
              "description": "the pair whose second element is returned",
              "type": {"pair": {"first": {"variable": "a"}, "second": {"variable": "b"}}},
              "isLazy": false}],
          "result": {"type": {"variable": "b"}}},
        "isPure": true,
        "isTotal": true}}]}