doc[compressed]: commentation
This commit is contained in:
parent
4f31b90a26
commit
4aff1a56d6
1 changed files with 6 additions and 0 deletions
|
@ -20,8 +20,10 @@ import Language.Brainfuck.Instruction qualified as Instruction
|
||||||
data CompressedInstruction
|
data CompressedInstruction
|
||||||
= Add Word8
|
= Add Word8
|
||||||
| Subtract Word8
|
| Subtract Word8
|
||||||
|
-- add and sub wrap when doing more than 255 because Brainfuck operates on u8-cells
|
||||||
| MoveRight Natural
|
| MoveRight Natural
|
||||||
| MoveLeft Natural
|
| MoveLeft Natural
|
||||||
|
-- disallows moving a negative amount of steps in a direction
|
||||||
| ReadByte
|
| ReadByte
|
||||||
| PutByte
|
| PutByte
|
||||||
| Loop (Vector CompressedInstruction)
|
| Loop (Vector CompressedInstruction)
|
||||||
|
@ -86,3 +88,7 @@ uncompress = Vector.concatMap uncompressSingle
|
||||||
ReadByte -> Vector.singleton Instruction.ReadByte
|
ReadByte -> Vector.singleton Instruction.ReadByte
|
||||||
Loop body -> Vector.singleton $ Instruction.Loop (uncompress body)
|
Loop body -> Vector.singleton $ Instruction.Loop (uncompress body)
|
||||||
|
|
||||||
|
-- >>> let source = Vector.replicate 300 Instruction.Increment in source == (uncompress . compress) source
|
||||||
|
-- False
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue