text-register-machine-0.4.0: A Haskell implementation of the 1# Text Register Machine

Safe HaskellSafe-Infered

Language.TRM.Programs

Contents

Synopsis

1# Examples

succBB' :: WordSource

Yields the successor of the backwards-binary number in register 1.

 *Language.TRM> decodeBB <$> phi succBB [(1, encodeBB 0)]
 Just 1
 *Language.TRM> decodeBB <$> phi succBB [(1, encodeBB 119)]
 Just 120

plusBB' :: WordSource

Yields the sum of two backwards-binary numbers in registers 1 and 2.

 *Language.TRM> decodeBB <$> phi plusBB [(1, encodeBB 2), (2, encodeBB 3)]
 Just 5
 *Language.TRM> decodeBB <$> phi plusBB [(1, encodeBB 100), (2, encodeBB 20)]
 Just 120

1#L Programs

clearSource

Arguments

:: Register

Register to clear.

-> LComp () 

moveSource

Arguments

:: Register

Source Register.

-> Register

Destination Register.

-> LComp () 

copySource

Arguments

:: Register

Source Register.

-> Register

Destination Register.

-> LComp () 

compare :: Register -> Register -> LComp ()Source

Compares the contents of the given registers for equality, leaving a 1 in the first register if they are, or nothing otherwise. The contents of both registers are destroyed in the process.

succBBSource

Arguments

:: Register

Register to increment.

-> LComp () 

addBB :: Register -> Register -> LComp ()Source

Add the two argument registers using primitive recursion, leaving the result in the first.

 *Language.TRM.Programs> decodeBB <$> runL (addBB 1 2) [(1, encodeBB 100), (2, encodeBB 20)]
 Just 120