brainfuck-monad-0.0.1: BrainFuck monad

Safe HaskellSafe-Inferred
LanguageHaskell98

Control.Monad.BrainFuck

Synopsis

Documentation

newtype BrainFuck a Source

Constructors

BrainFuck (DataPointer -> ([Char], DataPointer, a)) 

Instances

func :: BrainFuck f -> DataPointer -> ([Char], DataPointer, f) Source

Retrieve the inner function

brainfuck :: BrainFuck f -> String Source

Evaluate the monad and get a brainfuck program

next :: BrainFuck () Source

move data pointer right

close :: BrainFuck () Source

if byte at data pointer is nonzero, jump to command after matching open

open :: BrainFuck () Source

if byte at data pointer is zero, jump to command after close

input :: BrainFuck () Source

input byte, storing at data pointer

output :: BrainFuck () Source

output byte at data pointer

decr :: BrainFuck () Source

decrement data

incr :: BrainFuck () Source

increment data

prev :: BrainFuck () Source

move data pointer left

cmd :: Char -> BrainFuck () Source

Adds an arbitrary character to the program. Should not be used directly.

cmd' :: (DataPointer -> DataPointer) -> Char -> BrainFuck () Source

Adds an arbitrary character to the program, and updates the data pointer. Should not be used directly.

multi :: BrainFuck () -> Int -> BrainFuck () Source

Run an action multiple times.

addr :: BrainFuck DataPointer Source

Gets the current address of the data pointer.

setAddr :: Integer -> BrainFuck () Source

Moves the data pointer to a specific address.

loopUnless0 :: BrainFuck () -> BrainFuck () Source

The loop is only entered if the byte at the data pointer is not zero.

On entry, the loop body is run, and then it loops when the byte at the data pointer is not zero.

brainfuckConstants :: (Constants -> BrainFuck a) -> String Source

Let's run programs with data cells 0-8 reserved to always contain the numbers 0 to 8.

These constants will make brainfuck quite a bit easier to use!

at :: Constants -> Integer -> BrainFuck () Source

Sets data pointer to point to one of the Constants.

loop :: Constants -> BrainFuck () -> BrainFuck () Source

Run an action in a loop, until it sets its data pointer to 0.

forever :: Constants -> BrainFuck () -> BrainFuck () Source

Runs an action in an infinite loop.

demo :: String Source

Prints out the ASCII table, starting with space, repeatedly.

TODO: Only print printable characters.