Skip to content

Releases: 0xLet/Chain

Chain Head

03 Mar 02:38
e693d4d
Compare
Choose a tag to compare

Head Functions

runHead

func runHead(
        name: String? = nil,
        input: Variable? = nil,
        logging: Bool = false
    ) -> Variable

dropHead

func dropHead() -> Chain?

Chain Output

02 Mar 02:32
a431a47
Compare
Choose a tag to compare

Example Code

let output = Chain.link(
            .out { "First" },
            .link( .in {
                print("Value: \($0)")
            }, .multi(
                [
                    .multi([
                        .end,
                        .end,
                        .end
                    ]),
                    .link(.out {
                        "Link"
                    }, .link(
                        .out { "Last" },
                        .complete(.inout { value in
                            guard case .string(let value) = value else {
                                XCTFail()
                                return .void
                            }
                            
                            return  .string("\(value) !!!")
                        })
                    ))
                ]
            ))
        )
        .run(name: "ChainTests-testOutput")

Normal Chain Output

(lldb) po output
 Variable
   array : 2 elements
     0 : Variable
      - string : "First"
     1 : Variable
       array : 2 elements
        - 0 : E.Variable.void
         1 : Variable
           array : 2 elements
             0 : Variable
               array : 3 elements
                 0 : Variable
                   array : 1 element
                    - 0 : E.Variable.void
                 1 : Variable
                   array : 1 element
                    - 0 : E.Variable.void
                 2 : Variable
                   array : 1 element
                    - 0 : E.Variable.void
             1 : Variable
               array : 2 elements
                 0 : Variable
                  - string : "Link"
                 1 : Variable
                   array : 2 elements
                     0 : Variable
                      - string : "Last"
                     1 : Variable
                       array : 1 element
                         0 : Variable
                          - string : "Last !!!"

Flattened Chain Output

(lldb) po output.flatten
 Variable
   array : 8 elements
     0 : Variable
      - string : "First"
    - 1 : E.Variable.void
    - 2 : E.Variable.void
    - 3 : E.Variable.void
    - 4 : E.Variable.void
     5 : Variable
      - string : "Link"
     6 : Variable
      - string : "Last"
     7 : Variable
      - string : "Last !!!"

Chain.link

11 Jan 19:13
Compare
Choose a tag to compare
Chain.link(
    { print("Chain.link") },
    .complete { print("Chain.complete") }
)
.run()