A functional programming method, system, device and medium supporting pipeline programming and algebraic data types
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGZHOU YUNBIAO NETWORK TECH CO LTD
- Filing Date
- 2026-03-05
- Publication Date
- 2026-05-29
Smart Images

Figure CN122111403A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of programming technology, specifically to a functional programming method, system, device, and medium that supports pipe programming and algebraic data types. Background Technology
[0002] Functional programming (FP) is a programming paradigm based on mathematical functions, emphasizing immutability, lack of side effects, and declarative programming. Modern programming languages such as Haskell, F#, and Scala support functional programming features, but still have certain limitations in areas such as the integration of object-oriented and functional programming and the expressive power of pipeline programming.
[0003] Furthermore, existing pipe programming models are mostly based on simple forward pipe operators (such as F#'s |> and Elixir's |>), lacking support for complex processes such as pipe branching, conditional jumps, parameter position control, and resetting state within the pipe. Meanwhile, algebraic data types (ADTs) are mostly implemented independently in existing programming languages, lacking deep integration with pipe programming, resulting in limited code expressiveness and logical redundancy.
[0004] Therefore, there is an urgent need for a new type of programming language system that can integrate algebraic data types and pipeline programming under a unified syntax framework to improve code readability, maintainability, and expressiveness. Summary of the Invention
[0005] (a) Technical problems to be solved
[0006] To address the shortcomings of existing technologies, this invention provides a functional programming method, system, device, and medium that supports pipeline programming and algebraic data types. This invention provides rigorous data modeling through algebraic data types and constructs readable, maintainable, and powerful data processing flows through highly flexible pipeline programming, thereby improving the readability, maintainability, and expressiveness of programming code. This invention is applicable to various demanding fields such as financial payments, real-time analysis, and system integration.
[0007] (II) Technical Solution
[0008] To address the aforementioned technical problems, the present invention provides the following first aspect of the technical solution: a functional programming method supporting pipe programming and algebraic data types, comprising:
[0009] Analyze the business to extract business concepts and business logic;
[0010] Define the data structure of business concepts using algebraic data types;
[0011] Abstract business logic using functional programming to define corresponding functions and implementation steps;
[0012] Pipeline programming is used to implement business logic based on algebraic data types, functions, and implementation steps.
[0013] Preferably, algebraic data types are defined using operators.
[0014] Preferably, the algebraic data type includes type aliases, product types, and / or sum types.
[0015] Preferably, pipe programming includes different pipe operators and control structures.
[0016] Preferably, pipe operators include forward pipe operators, branch pipe operators, and / or arrow operators; control structures include parameter position indicators, numeric labels, and / or pipe jumps and interrupts; pipe programming also includes pipe state variables, object member access, and / or Neta pipes.
[0017] Preferably, the functional programming method supporting pipe programming and algebraic data types further includes: performing branch matching processing on different algebraic data types through pattern matching to obtain multiple matching branches, wherein pattern matching is implemented through keywords; further, performing pipe programming according to the algebraic data type, function and implementation steps corresponding to each matching branch to obtain the corresponding pipe operation code block.
[0018] Preferably, the functional programming approach that supports pipe programming and algebraic data types also includes: importing algebraic data types and / or functions through global scope identifiers.
[0019] To address the aforementioned technical problems, the present invention provides the following second aspect of the technical solution: a system for implementing the functional programming method supporting pipe programming and algebraic data types as described in the first aspect above, the system comprising:
[0020] The business analysis module is used to analyze business processes to extract business concepts and business logic.
[0021] The data structure definition module is used to define the data structure of business concepts using algebraic data types;
[0022] The business logic abstraction module is used to abstract business logic using functional programming to define corresponding functions and implementation steps;
[0023] The business logic implementation module is used to implement business logic through pipeline programming based on algebraic data types, functions, and implementation steps.
[0024] To solve the above-mentioned technical problems, the present invention provides the following third aspect of the technical solution: an electronic device, including a memory and a processor coupled to each other, the memory storing program instructions, and the processor executing the program instructions to implement the functional programming method supporting pipe programming and algebraic data types as described in the first aspect of the technical solution above.
[0025] To solve the above-mentioned technical problems, the present invention provides the following fourth aspect of the technical solution: a computer-readable storage medium storing program instructions thereon, wherein when the program instructions are executed by a processor, a functional programming method supporting pipe programming and algebraic data types as described in the first aspect of the technical solution above is implemented.
[0026] (III) Beneficial Effects
[0027] Compared with existing technologies, this invention provides a functional programming method, system, device, and medium that supports pipeline programming and algebraic data types, and has the following beneficial effects: This invention provides a novel programming language system that can integrate algebraic data types and pipeline programming within a unified syntax framework. This invention provides rigorous data modeling through algebraic data types and constructs readable, maintainable, and powerful data processing flows through highly flexible pipeline programming, thereby improving the readability, maintainability, and expressiveness of programming code. This invention is applicable to various high-requirement fields such as financial payment, real-time analysis, and system integration, demonstrating the positive exploration of modern programming languages in paradigm fusion and syntax innovation. Attached Figure Description
[0028] Figure 1 This is a flowchart illustrating the steps of a first embodiment of a functional programming method supporting pipe programming and algebraic data types according to the present invention.
[0029] Figure 2 This is a flowchart illustrating the steps of a second embodiment of a functional programming method supporting pipe programming and algebraic data types according to the present invention.
[0030] Figure 3 This is a schematic diagram of the electronic device of the present invention;
[0031] Figure 4 This is a schematic diagram of the framework of the computer-readable storage medium of the present invention. Detailed Implementation
[0032] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0033] like Figure 1 As shown, the first embodiment of the functional programming method supporting pipeline programming and algebraic data types of the present invention includes the following steps S101-S104:
[0034] S101. Analyze the business to extract business concepts and business logic. In this step S101, the business can be analyzed by abstracting and modeling the business domain, business problems, and / or business requirements, thereby extracting business concepts and business logic.
[0035] S102. Define the data structure of business concepts using algebraic data types.
[0036] Algebraic Data Types (ADTs) are a key concept in functional programming, used to describe the composition of data structures. They combine simple types into more complex data types, giving functional programming languages a high degree of abstraction and flexibility. Preferably, this invention defines algebraic data types using operators, specifically the :: operator. However, other symbols can also be used to represent these operators; no further restrictions are placed here.
[0037] Preferably, the algebraic data type includes type aliases, product types, and / or sum types. All data types are algebraic data types and support definition and reference in global or local scopes. The specific descriptions of each algebraic data type are as follows.
[0038] (1) Type aliases: Give existing types semantic names to enhance code readability. An example of a type alias definition is as follows:
[0039]
[0040] (2) Product type: Includes tuples and records, used for structured data modeling. An example definition of the product type is as follows:
[0041]
[0042]
[0043] (3) and Type: Supports enumeration types with data, used for modeling categorical data in the real world. An example definition of the and type is as follows:
[0044]
[0045] The above step S102 defines a precise data structure for business concepts using an algebraic data type (ADT), ensuring type safety and data integrity.
[0046] S103. Abstract the business logic using functional programming to define the corresponding functions and implementation steps.
[0047] Functional Programming (FP) is a programming paradigm based on mathematical functions, emphasizing immutability, side-effect-free operation, and declarative programming. In step S103 above, business logic is abstracted and analyzed using a functional programming mindset to define corresponding functions and implementation steps. These functions are pure functions without side effects, and the implementation steps are algorithms. It can be understood that this invention uses algebraic data types to model business data, and functions are used to process algebraic data types, i.e., ADT data.
[0048] S104. Perform pipeline programming based on algebraic data types, functions, and implementation steps to implement business logic.
[0049] Pipe programming provides smooth data flow. Preferably, the pipe programming of this invention includes different pipe operators and control structures; that is, pipe programming is performed using pipe operators and control structures to write code statements. Specifically, pipe operators include forward pipe operators, branch pipe operators, and / or arrow operators; control structures include parameter position indicators, numeric labels, and / or intra-pipe jumps and interrupts. The pipe operators and control structures of this invention are described in detail below.
[0050] (1) Forward pipe operator |>: This is the basic pipe operator used to connect multiple functions to form a data processing pipeline. Data flows from left to right, which greatly improves the readability and logical coherence of the code. It can be understood that the above |> represents the forward pipe operator; the same applies to other pipe operators and control structures, etc., which will not be elaborated on below.
[0051] (2) Branch pipe operator >>: This is the pipe conditional operator, which supports pattern matching and conditional branching on intermediate results of the pipe. It is used to perform pattern matching on the return value of the previous function, and can jump or implement different logic based on the result. An example of the branch pipe operator >> is as follows:
[0052]
[0053] (3) Arrow symbol ->: Its corresponding arrow statement is used to insert side-effect operations or define anonymous callback functions between pipeline steps. The arrow symbol -> can be used in the following two scenarios in pipeline programming:
[0054] Scenario 1: After the previous function has finished executing and before the next function in the pipeline is executed, the code corresponding to the arrow symbol can be executed to handle parameters, as shown in the following example:
[0055]
[0056] Scenario 2: Defining an anonymous callback function when the parameter in the pipeline function is a callback function, as shown in the example below:
[0057]
[0058] (4) Parameter position indicator: This corresponds to the position indicator, which allows specifying which parameter of the next function will be the result of the previous step. In other words, it indicates which parameter of the next function will be the return value of the previous function. The specific format of the parameter position indicator is: |> function-name([expression]) [, function position number indicator], where the function position number indicator is a number, starting from 1. If the function position number indicator is a negative integer, it indicates right-to-left; 0 indicates a syntax error. An example is shown below:
[0059]
[0060] Furthermore, if the function position numeric indicator is not specified, it defaults to using the output of the previous function as the first argument of the next function, as shown in the following example:
[0061]
[0062] (5) Numeric Label: Numeric labels provide a unique identifier for pipeline steps. This invention introduces pipeline steps with numeric labels to facilitate jumping to a specified numeric label step within the pipeline.
[0063] (6) Jumping and interrupting within the pipeline: It supports the `continue` and `break` statements to achieve logical jumps or early exits within the pipeline; the above-mentioned numeric labels and `continue` facilitate jumps between different branches under management. Numeric labels are used for identification, and then the `continue` keyword is used for jumps. The `continue` keyword indicates that the jump is only within the pipeline and will not exit the pipeline; that is, the numeric label provides a unique identifier for the pipeline step, and `continue` can jump to the specified label step within the pipeline and optionally update the pipeline's passed value; the present invention, through the above-mentioned numeric labels, jumping and interrupting within the pipeline and other control structures, can give the pipeline jump capabilities similar to traditional flowcharts, while maintaining the cleanliness of the pipeline syntax. Among them, examples of numeric labels and `continue` are as follows:
[0064]
[0065] In addition, the above-mentioned "break" corresponds to pipeline interruption, which is used to exit the entire pipeline in advance, i.e., pipeline jump-out. An example is as follows:
[0066]
[0067] Furthermore, preferably, the pipe programming of the present invention also includes pipe state variables, object member access, and / or Neta pipes, that is, during the pipe programming process, pipe state variables, object member access, and / or Neta pipes can be used to write code statements. The specific descriptions of the aforementioned pipe state variables, object member access, and Neta pipes are as follows.
[0068] (1) Pipe state variable b:pipe: used to pass and modify intermediate results in the pipe; the pipe state variable is a language variable provided by this invention for functional programming. The value of the pipe state variable is the result of the previous function call and the input parameter of the next function in the pipe; developers can modify the value of the pipe state variable to affect the next function call. An example of the pipe state variable is as follows:
[0069]
[0070] (2) Accessing object members with @self: Directly accesses object members within the pipeline. When a function in the pipeline returns a value of type record, class, etc., direct member access can be performed when the next function is executed (note the difference from this). Examples of object member access are as follows:
[0071]
[0072] (3) Neta pipes: also known as neta blocks, which support the construction of dynamic pipes in loop or conditional contexts. As an advanced feature, neta pipes allow pipes to be embedded in loops or conditional contexts to achieve fully Turing-complete flow control. The following example shows the use of neta blocks in pipe programming, and the combination of neta and pipe programming is Turing-complete. The elements that satisfy Turing completeness are: unlimited storage, conditional branching, loop statements, and general computation rules. An example of a neta pipe is as follows:
[0073]
[0074] In addition, preferably, the control structure for pipe programming in this invention may further include @pipe, which is used to specify the starting value of the pipe in the above-mentioned Neta pipe, further enhancing the flexibility and expressiveness of pipe programming. @pipe indicates that it is used as the starting value of the entire pipe in the Neta pipe, and serves as the parameter of the first function in the pipe; an example of @pipe is as follows:
[0075]
[0076] Furthermore, preferably, the pipe programming of the present invention also supports single-line and multi-line writing, with a blank line indicating the end of the pipe, and the format is free. Examples of single-line pipes and multi-line pipes are as follows:
[0077]
[0078]
[0079] Furthermore, preferably, the present invention can import algebraic data types, variables, and / or functions through a global scope identifier, which can be represented by g:. Specifically, algebraic data types, functions, or variables can be imported as needed through the import statement, avoiding naming conflicts and enhancing modularity and reusability.
[0080] It is understood that after steps S101-S104 above, the present invention implements the business logic and obtains the pipeline programming code, i.e., the pipeline operation code. Further, the pipeline programming code can be compiled using the following compilation method: First, the input pipeline programming code is processed by a lexer and a parser to generate an abstract syntax tree (AST). Then, based on the AST, a bytecode file (called an RSE file) in intermediate representation form is generated through compilation operations. The following language design rules can be adopted: the forward pipe symbol |> uses the data on the left as the input parameter of the expression on the right, defaulting to the first parameter, or specifying the specific parameter position using positive / negative integers; the branch pipe symbol >> allows selective execution of the corresponding branch expression based on the input data conditions; the pipeline callback function mechanism allows the expression after the arrow symbol -> to be called after the pipeline statement execution is complete; the pipeline jump flag (continue n. statement) supports jumping to the statement at the specified label (n.) to continue execution; the pipeline break flag (break) allows early exit from the current pipeline or nested pipelines, entering the corresponding outer pipeline to execute subsequent code segments. Finally, the generated RSE file is deployed to a virtual machine (Rhino) for execution. The above series of standardized operations enable efficient compilation and flexible execution of pipelined code, suitable for modular processing of complex tasks and scalable programming needs.
[0081] Furthermore, preferably, for scenarios where different algebraic data types correspond to different business logic, this invention introduces pattern matching, enabling developers to perform branching processing based on the data type and content. For example... Figure 2 As shown, a second embodiment of the functional programming method supporting pipeline programming and algebraic data types of the present invention includes the following steps S201-S205:
[0082] S201. Analyze the business to extract business concepts and business logic.
[0083] S202. Define the data structure of business concepts using algebraic data types.
[0084] S203. Abstract the business logic using functional programming to define the corresponding functions and implementation steps.
[0085] S204. Pattern matching is used to perform branch matching on different algebraic data types to obtain multiple matching branches. It can be understood that different matching branches correspond to different algebraic data types, functions, and implementation steps.
[0086] The pattern matching of this invention extends existing branching statements. It supports deep pattern matching for algebraic data types, with matching conditions including type discrimination, value comparison, and structure deconstruction to enable branching processing for different data forms. In other words, pattern matching not only supports conditional matching for basic types but also deeply integrates algebraic data types. Through this invention's pattern matching, developers can perform branching processing based on data type and content, such as matching different payment methods and executing corresponding logic. The pattern matching syntax supports deconstruction of record fields, conditional judgment, and value binding, making the expression of business logic more intuitive and compact, especially suitable for handling domain objects with multiple states or forms, such as order status and user authentication results. In one embodiment, the above pattern matching can be implemented using the `case` keyword, i.e., pattern matching adopts a `case` statement structure. Furthermore, in other embodiments, pattern matching can also be implemented using the `switch` keyword or other keywords. That is, the pattern matching of this invention can be implemented using `case`, `switch`, or other keywords, without further limitations. An example of pattern matching is as follows:
[0087]
[0088] S205. Based on the algebraic data type, function, and implementation steps corresponding to each matching branch, perform pipeline programming to obtain the corresponding pipeline operation code block to implement the business logic.
[0089] It can be understood that each matching branch corresponds to a different pipeline operation code block, forming multiple parallel processing paths; at runtime, algebraic data types are processed through different matching branches, and after the multiple pipeline operation code blocks have undergone their respective processing, the corresponding results are output.
[0090] The main technical points of this invention are summarized below.
[0091] The programming language used in this invention can be specifically defined as the Phoenix programming language (or simply Phoenix). The Phoenix programming language integrates object-oriented and functional programming paradigms, and on this basis, has developed a unique functional programming system. This system revolves around the following key features: algebraic data types, pattern matching, and pipeline programming. Algebraic data types are defined using the `::` operator and include type aliases, product types (such as tuples and records), and sum types (enumeration types with data), aiming to provide a type-safe and semantically clear modeling method for data structures in the real world. Summation types are particularly suitable for categorical data, such as payment methods and color types, and can carry multiple variations within a single type, each with data of different structures, thereby enhancing the expressiveness and maintainability of the code. All type instances are immutable by default, conforming to the immutability principle of functional programming, which helps reduce side effects and concurrency risks.
[0092] In terms of name and scope management, Phoenix introduces `g:` as a globally visible identifier and supports modular development through a flexible import mechanism. The `import` statement allows functions, data types, or combinations thereof to be imported as needed, and prefixes can be added to avoid naming conflicts. This design ensures code encapsulation while providing convenience for cross-module reuse, making it particularly suitable for the development of large projects or libraries. Furthermore, this invention avoids potential ambiguity at the syntactic level by requiring that data types and functions with the same fully qualified name (FQN) cannot have the same name.
[0093] Pattern matching has been enhanced in Phoenix, supporting not only basic type conditional matching but also deep integration with algebraic data types. Through pattern matching, developers can branch processing based on data type and content, such as matching different payment methods and executing corresponding logic. The pattern matching syntax supports destructuring record fields, conditional judgments, and value binding, making business logic expression more intuitive and compact. It is particularly suitable for handling domain objects with multiple states or forms, such as order status and user authentication results.
[0094] Pipeline programming is the most distinctive feature of Phoenix functional programming in this invention. The forward pipe symbol |> is used to connect multiple functions, forming a data processing chain similar to a factory assembly line, with data flowing from left to right, greatly improving code readability and logical coherence. Pipelines support single-line and multi-line writing, with blank lines indicating the end of a pipeline, and the format is flexible. Furthermore, Phoenix extends the control capabilities of pipelines: parameter position indicators (e.g., , 2) can specify which parameter the result of the previous step should be used as the next function's parameter; the branching pipe symbol >> introduces pattern-matching-based branching, allowing dynamic adjustments to the flow based on intermediate results; and the arrow symbol -> is used to insert side-effect operations or define anonymous callback functions between steps.
[0095] To support more complex flow control, Phoenix of this invention introduces pipe steps with numerical labels, and a continue and break mechanism. Numerical labels provide unique identifiers for pipe steps; continue allows jumping within the pipe to a specified labeled step and optionally updates the pipe's passed values; break is used to prematurely exit the entire pipe. This control structure gives pipes the jumping capabilities of traditional flowcharts while maintaining the cleanliness of pipe syntax. Furthermore, the special variable b:pipe is used to pass and modify intermediate results within the pipe, @self supports direct access to object members within the pipe, and @pipe is used to specify the pipe's starting value in the neta structure, further enhancing the flexibility and expressiveness of the pipe.
[0096] Furthermore, Neta pipes, as an advanced feature, embed pipes within loops or conditional contexts to achieve fully Turing-complete flow control. This allows developers to nest branches, loops, interruptions, and continuations within pipes, creating complex data processing and business workflows. Combined with exception handling (catch blocks), pipes can gracefully handle errors, ensuring process robustness. These mechanisms make Phoenix pipes suitable not only for simple data transformations but also for complex scenarios such as business process orchestration, real-time event processing, and state machine implementation.
[0097] In summary, this invention has the following technical advantages: (1) Strong syntactic expressiveness: Through the deep integration of algebraic data types and pipeline programming, it supports intuitive and declarative modeling of complex business logic. (2) Flexible flow control: Through various different pipeline operators and control structures, it realizes mechanisms such as pipeline branching, jumping, and state resetting, enhancing the dynamic control capability of data flow. (3) High code maintainability: Algebraic data types and pattern matching improve the type safety and logical clarity of the code. (4) Easy integration and extension: This invention supports seamless integration with object-oriented programming, database operations (Micro SQL), and other features. (5) Optimized execution efficiency: Pipeline programming can support compile-time optimization and lazy evaluation, improving runtime performance.
[0098] In summary, the Phoenix functional programming framework of this invention provides rigorous data modeling through algebraic data types, achieves clear branching logic through pattern matching, and constructs readable, maintainable, and powerful data processing workflows through highly flexible pipeline programming. This invention balances expressiveness, type safety, and control flexibility, making it suitable for various demanding fields such as financial payments, real-time analysis, and system integration, demonstrating the positive exploration of paradigm convergence and syntactic innovation in modern programming languages. An example of this invention's application in a financial payment system is provided below.
[0099] With the acceleration of digital transformation of financial services, payment systems are becoming increasingly complex, involving diversified needs such as multi-channel payment, multi-currency settlement, real-time risk control, and compliance checks. Traditional object-oriented payment system design often faces the following challenges: (1) Rigid processes: payment processes are mostly hard-coded in business logic, making it difficult to dynamically adjust and reuse them. (2) Insufficient type security: payment data types are loosely defined, which can easily lead to data inconsistencies or type errors. (3) Complex rule expression: business rules such as risk control rules and fee calculations are scattered in many places, making it difficult to manage and visualize them uniformly. (4) Poor scalability: adding new payment channels or business rules requires modifying the core code, affecting system stability. In this regard, the functional programming method of the present invention, which supports pipeline programming and algebraic data types, can provide a programming and modeling system that can ensure type security, flexibly model payment processes, and support dynamic rule combination. Through the present invention, a financial payment system modeling method and system based on functional pipeline programming can be established. By introducing the algebraic data types, pattern matching, and pipeline programming mechanism in the Phoenix language, a type-safe, composable, and visualized payment process modeling framework can be constructed.
[0100] When applied to a financial payment system, this invention analyzes business processes to extract business concepts and logic. Specific business concepts may include payment accounts, payment methods, etc. Furthermore, it defines the data structure of business concepts using algebraic data types and abstracts the business logic using functional programming to define corresponding functions and implementation steps. Pattern matching is used to perform branch matching on different algebraic data types to obtain multiple matching branches. Pipeline programming is then performed based on the algebraic data type, function, and implementation steps corresponding to each matching branch to obtain the corresponding pipeline operation code block. Specifically, examples of relevant programming code for a financial payment system established using this invention are as follows.
[0101] (1) Data type modeling in the payment domain
[0102] The system uses algebraic data types to semantically model entities in the payment domain:
[0103] The Phoenix code for the payment account type is as follows:
[0104]
[0105] The following is a Phoenix code snippet for payment method modeling:
[0106]
[0107] The Phoenix code snippet defining the total payment method type is as follows:
[0108]
[0109] (2) Pipeline modeling of payment process
[0110] The payment process is modeled as a series of composable pipeline steps, each corresponding to a business function, and the Phoenix code snippet implementing this is as follows:
[0111]
[0112] It is understandable that the above uses the sum type, product type, and type alias defined in algebraic data types for payment; and the business logic code for payment processing is implemented using pipeline programming. The data types defined by algebraic data types (ADT) are also used in the pipeline programming code for subsequent business logic implementation.
[0113] (3) Risk control rules as pipeline branches
[0114] Risk control rules can be dynamically matched and intercepted using the branch pipe symbol >>. The Phoenix code snippet demonstrating this is as follows:
[0115]
[0116] (4) Fee calculation and strategy combination
[0117] Fee calculation can be achieved by combining multiple strategy functions through a pipeline, as shown in the Phoenix code snippet below:
[0118]
[0119] (5) Unified pipeline interface for multiple payment channels
[0120] Different payment channels can be abstracted and invoked through a unified pipeline interface, as shown in the Phoenix code snippet below:
[0121]
[0122] (6) Real-time transaction monitoring and pipeline tracking
[0123] The pipeline execution process can be monitored, recorded, and audited in real time. The Phoenix code snippet implementing this is as follows:
[0124]
[0125] As can be seen from the above code snippets for financial payment modeling, by deeply integrating the functional pipeline programming technology of this invention with the financial payment field, a type-safe, flexible, scalable, easy-to-use, and real-time monitoring-supporting payment system modeling method is proposed. The aforementioned financial payment system not only improves the reliability and maintainability of the payment process but also rapidly responds to business changes through pipeline combination and rule plug-and-play mechanisms, demonstrating strong practical value and promising prospects for industry promotion.
[0126] Furthermore, this invention also provides a system for implementing the aforementioned functional programming method supporting pipeline programming and algebraic data types. This system includes: a business analysis module for analyzing business processes to extract business concepts and business logic; a data structure definition module for defining data structures for business concepts using algebraic data types; a business logic abstraction module for abstracting business logic using functional programming to define corresponding functions and implementation steps; and a business logic implementation module for implementing business logic through pipeline programming based on algebraic data types, functions, and implementation steps. The specific working principle of this system is detailed in the corresponding description of the aforementioned functional programming method supporting pipeline programming and algebraic data types, and will not be elaborated upon here.
[0127] like Figure 3As shown, the present invention also provides an electronic device 3, which includes a memory 31 and a processor 32 coupled to each other. The memory stores program instructions, and the processor 32 is used to execute the program instructions stored in the memory 31 to implement any of the above-mentioned functional programming methods that support pipeline programming and algebraic data types. In a specific implementation scenario, the above-mentioned electronic device 3 may include, but is not limited to, a microcomputer or a server. In addition, the electronic device 3 may also include mobile devices such as laptops and tablets, which are not limited here.
[0128] Specifically, the processor 32 is used to control itself and the memory 31 to implement any of the aforementioned functional programming methods that support pipeline programming and algebraic data types. The processor 32 can also be called a CPU (Central Processing Unit). The processor 32 may be an integrated circuit chip with signal processing capabilities. The processor 32 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor. Furthermore, the processor 32 can be implemented using integrated circuit chips.
[0129] In addition, such as Figure 4 As shown, the present invention also provides a computer-readable storage medium 4, on which program instructions 41 are stored. When executed by a processor, the program instructions 41 implement any of the aforementioned functional programming methods that support pipe programming and algebraic data types. The storage medium 4 may include various media capable of storing program instructions, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0130] It should be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0131] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A functional programming method supporting pipe programming and algebraic data types, characterized in that, include: Analyze the business to extract business concepts and business logic; The data structure of the business concept is defined using algebraic data types; The business logic is abstracted using functional programming to define corresponding functions and implementation steps; Pipeline programming is performed based on the algebraic data type, the function, and the implementation steps to implement the business logic.
2. The functional programming method supporting pipeline programming and algebraic data types according to claim 1, characterized in that: The algebraic data type is defined by operators.
3. The functional programming method supporting pipeline programming and algebraic data types according to claim 1, characterized in that: The algebraic data types include type aliases, product types, and / or sum types.
4. The functional programming method supporting pipe programming and algebraic data types according to claim 1, characterized in that: The pipeline programming includes different pipeline operators and control structures.
5. The functional programming method supporting pipe programming and algebraic data types according to claim 4, characterized in that: The pipe operators include forward pipe operators, branch pipe operators, and / or arrow operators; the control structures include parameter position indicators, numeric labels, and / or pipe jumps and interrupts; the pipe programming also includes pipe state variables, object member access, and / or Neta pipes.
6. The functional programming method supporting pipe programming and algebraic data types according to claim 1, characterized in that, Also includes: Multiple matching branches are obtained by performing branch matching on different algebraic data types through pattern matching, wherein the pattern matching is implemented through keywords; further, pipe programming is performed according to the algebraic data type, the function and the implementation steps corresponding to each matching branch to obtain the corresponding pipe operation code block.
7. The functional programming method supporting pipe programming and algebraic data types according to claim 1, characterized in that, Also includes: Import the algebraic data type and / or the function using the global scope identifier.
8. A system for implementing a functional programming method supporting pipeline programming and algebraic data types as described in any one of claims 1-7, characterized in that, The system includes: The business analysis module is used to analyze business processes to extract business concepts and business logic. The data structure definition module is used to define the data structure of the business concept using algebraic data types. The business logic abstraction module is used to abstract the business logic using functional programming to define corresponding functions and implementation steps; The business logic implementation module is used to perform pipeline programming to implement the business logic based on the algebraic data type, the function, and the implementation steps.
9. An electronic device comprising a memory and a processor coupled to each other, the memory storing program instructions, characterized in that: The processor is used to execute the program instructions to implement the functional programming method that supports pipe programming and algebraic data types as described in any one of claims 1-7.
10. A computer-readable storage medium having program instructions stored thereon, characterized in that: When the program instructions are executed by the processor, they implement the functional programming method that supports pipe programming and algebraic data types as described in any one of claims 1-7.