haskell-brainfuck: BrainFuck interpreter

[ language, library, mit, program ] [ Propose Tags ]

BrainFuck language interpreter. Provides a library for evaluation and an executable to evaluate brainfuck files. Evaluation happens under an arbitrary monad so programn can be evaluated doing IO to stdinstdout or in memory using the State monad.

[Skip to Readme]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS],
Dependencies base (>=4.7 && <4.8), bytestring (==, haskell-brainfuck, mtl (==, parsec (==3.1.5) [details]
License MIT
Copyright (c) 2014 Sebastian Galkin
Author Sebastian Galkin <paraseba@gmail.com>
Maintainer Sebastian Galkin <paraseba@gmail.com>
Category Language
Source repo head: git clone https://github.com/paraseba/haskell-brainfuck
Uploaded by paraseba at 2014-08-08T07:12:31Z
Distributions Debian:
Reverse Dependencies 1 direct, 0 indirect [details]
Executables brainfuck
Downloads 1844 total (5 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for haskell-brainfuck-

[back to package description]


Interpreter for the brainfuck programming language

Build Status

haskel-brainfuck is distributed as a library, but it also includes an executable to run brainfuck programs. You can find haskell-brainfuck in Hackage



import HaskBF.Eval
import qualified Data.ByteString.Lazy as BS
import Control.Monad.State

main = do
  -- The following will evaluate the file using stdin and stdout for I/O.
  -- Evaluation results in an EvalResult

  file <- BS.readFile "/path/to/file.bf"
  (EvalSuccess _) <- evalBS defaultIOMachine file
  print "ok"

  -- The following will evaluate the file using the State monad and input
  -- provided by input

  let input  = []
      output = []
      result = execState (evalStr simulatorMachine "+.>-.") (SimState input output)
  print $ simStateOutput result == [1, -1]


brainfuck fib.bf


You can run the test suite with

cabal test