~/bend-docscommunity

main.bend checks

raw source on the hub · import bend-edit-distance@0.1.0.0/main.bend as Main

5 imports
import Base
import ./Cli.bend as CLI
import ./EdlibTypes.bend as E
import ./Alignment.bend as A
import ./AlignmentCli.bend as AC

Types

type Peq source · line 12 · raw

Data

type Block source · line 16 · raw

Data

type Carry source · line 21 · raw

Data

Horizontal differences are -1, 0, or +1. Keep both signs explicit rather than relying on signed shifts or two's-complement arithmetic.

Definitions

def split_query.prepend source · line 24 · raw

@h:Char -> @parts:Pair(String, String) -> Pair(String, String)

def split_query source · line 29 · raw

@n:Nat -> @query:String -> Pair(String, String)

def build_peq_word source · line 39 · raw

@query:String -> @+symbol:Char -> @+bit:U32 -> U32

Bit i matches query[i]. Unused high bits are wildcards, as in buildPeq.

def build_peq_table source · line 50 · raw

@+depth:Nat -> @+query:String -> @+symbol:U32 -> @+step:U32 -> Peq

A byte-indexed immutable table replaces the C++ transformed alphabet. Low bits select branches, so lookup takes eight steps for every byte. Both halves of the table have equal, independent work and run in parallel.

def peq_get source · line 58 · raw

@table:Peq -> @+code:U32 -> @bit:Bool -> U32

def build_peq.step source · line 69 · raw

@parts:Pair(String, String) -> @tail:(@_:String -> List<&2, Peq>) -> List<&2, Peq>

def build_peq source · line 74 · raw

@fuel:Nat -> @query:String -> List<&2, Peq>

def ceil_div source · line 81 · raw

@+x:Nat -> @+y:Nat -> Nat

def init_blocks source · line 84 · raw

@n:Nat -> @+bottom:U32 -> List<&1, Block>

def calculate_block source · line 93 · raw

@block:Block -> @+eq:U32 -> @hin:Carry -> Pair(Block, Carry)

calculateBlock / Advance_Block from Myers. Addition intentionally wraps at 32 bits. Xv uses the original Eq, before the negative carry is added.

def advance_column.step source · line 112 · raw

@result:Pair(Block, Carry) -> @tail:(@_:Carry -> List<&1, Block>) -> List<&1, Block>

A column and consecutive target columns depend on their predecessor; parallelizing those calls would violate the Myers carry dependency.

def advance_column source · line 118 · raw

@blocks:List<&1, Block> -> @profiles:List<&2, Peq> -> @+symbol:U32 -> @hin:Carry -> List<&1, Block>

def get_block_cell_value source · line 133 · raw

@padding:Nat -> @+pv:U32 -> @+mv:U32 -> @score:U32 -> U32

getBlockCellValues(block)[W], without constructing the other 31 cells. Walking up a row subtracts its positive vertical difference and adds its negative difference. W is always in 0..31, never a whole extra block.

def last_block_score source · line 141 · raw

@blocks:List<&1, Block> -> @+padding:Nat -> Nat

def myers_calc_edit_distance_nw source · line 153 · raw

@target:String -> @+profiles:List<&2, Peq> -> @blocks:List<&1, Block> -> @+padding:Nat -> Nat

Unlimited NW evaluates every block once per target character. It needs only the current column; Ukkonen threshold bands and traceback storage are unnecessary for the distance-only, k = -1 interface.

def align_query source · line 162 · raw

@+query:String -> @target:String -> @+length:Nat -> Nat

def align_shorter source · line 169 · raw

@query:String -> @target:String -> @query_length:Nat -> @target_length:Nat -> @query_is_shorter:Bool -> Nat

def distance source · line 177 · raw

@query:String -> @target:String -> Nat

def edlib_align source · line 189 · raw

@query:String -> @target:String -> @config:0x483ba00627509c62188f937a7cfd8f76/EdlibTypes.AlignConfig -> 0x483ba00627509c62188f937a7cfd8f76/EdlibTypes.AlignResult

def response source · line 202 · raw

@query:String -> @target:String -> String

def run source · line 205 · raw

@args:List<&1, String> -> IO(Unit)

def main source · line 212 · raw

IO(Unit)