The brainfuck-tut package

[Tags:bsd3, library, program]

[Skip to Readme]


Change log
Dependencies array, base (>=4.7 && <5), brainfuck-tut [details]
License BSD3
Copyright (c) 2016 Allele Dev
Author Allele Dev
Category Language
Home page
Bug tracker
Source repository head: git clone git clone
Uploaded Fri Dec 30 18:00:38 UTC 2016 by alleledev
Distributions NixOS:
Downloads 1387 total (48 in the last 30 days)
0 []
Status Docs available [build log]
Last success reported on 2016-12-30 [all 1 reports]
Hackage Matrix CI




Maintainer's Corner

For package maintainers and hackage trustees

Readme for brainfuck-tut

Readme for brainfuck-tut-

Brainfuck: A Toy Implementation

This project exists to show what a Brainfuck evaluator might look like in Haskell.

The implementation is fairly well documented. I endeavored to make it readable.


Below is the abstract syntax tree for the BF language as implemented:

data Term
  = IncDP        -- >
  | DecDP        -- <
  | OutDP        -- ?
  | IncByte      -- +
  | DecByte      -- -
  | OutByte      -- .
  | InByte       -- ,
  | JumpForward  -- [
  | JumpBackward -- ]
  deriving (Show, Eq)

Evaluation Semantics

I followed the summary given on the wikipedia page closely. A few particulars to this implementation:

  • "Jump not found" errors abort evaluation and return the state of the tape
  • Out of bound errors are not detected
  • Evaluation proceeds until the instruction stream runs out


An executable is provided:

$ cabal build bfh
$ cabal run bfh
usage: bfh <size> <program>
$ cabal run bfh 10 ',.'