Copyright | (c) Sebastian Galkin, 2014 |
---|---|
License | MIT |
Maintainer | paraseba@gmail.com |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Provides a type and operations to implement the brainfuck tape. The tape has the concept of a pointer, and the pointer can be incremented or decremented.
- data Tape t = Tape [t] t [t]
- data ExecutionError a
- rTape :: Tape t -> t
- wTape :: t -> Tape t -> Tape t
- inc :: Num a => Tape a -> Tape a
- dec :: Num a => Tape a -> Tape a
- right :: Tape a -> Either (ExecutionError a) (Tape a)
- left :: Tape a -> Either (ExecutionError a) (Tape a)
- type BFExError = ExecutionError Int8
- type BFTape = Tape Int8
- blankTape :: BFTape
Documentation
data Tape t
Brainfuck tape. Constructor arguments correspond to - - 1. left of the current pointer - 2. current pointed value - 3. right of the current pointer - - The left part of the tape is reversed, so the first element of the list - is the rightmost position. The right list is normal order, its first element - is the leftmost one.
Tape [t] t [t] |
data ExecutionError a
Write element to the current position in the tape
Increment the currently pointed element
Decrement the currently pointed element
:: Tape a | The tape |
-> Either (ExecutionError a) (Tape a) | A new tape with its pointer pointing to the - element to the right of the pointer in the - original tape; or an execution error if the - tape to the right is exhausted |
Move the pinter to the right
:: Tape a | The tape |
-> Either (ExecutionError a) (Tape a) | A new tape with its pointer pointing to - the element to the left of the pointer in - the original tape; or an execution error if - the tape to the left is exhausted |
Move the pinter to the left
type BFExError = ExecutionError Int8
Execution error type for basic Brainfuck tapes