Show HN: Using Haskell to write an NES emulator

1 month ago 1

FuNes is a Nintendo Entertainment System (NES) emulator, written in Haskell.

Warning

This emulator is for research purposes. Do not use as your daily emulator. You can easily find more mature NES emulators on GitHub!

🔍 Why does this project exist?

FuNes is an experiment before anything else. The goal was to see if the functional paradigm would apply well to writting virtual machines and emulator, thus being written in Haskell.

While the goal is to have a working emulator, it is in no way 100% valid. Some features are not (yet) implemented (see here) and some behaviour may be invalid

Results of this little experiment

  • The different parts of the emulator (CPU, PPU, Bus) are isolated objects and computations on them were designed using Monads. This made testing a real pleasure. Moreover, I find the code overal quite elegant (e.g. for the opcodes).

  • The typeafety prevented some bit-level mistakes (especially when handling 2-byte addresses and 1-byte data), which is always welcome.

  • However, it feels like the functional paradigm didn't bring much else to the table, compared to a regular object-orented approach. Although, it should be noted that, in any case, was the functional paradigm an obstacle in the design and implementation of the emulator

Still wanna try out the emulator? Ok, here's how

You will need to have Stack and the SDL2 library installed.

# In the cloned repository stack build stack run -- ./my_rom.nes # The path to the rom to use

Note: stack install will install the emulator as funes-exe

  • Select: Space
  • Start: Enter
  • A: A
  • B: S or Z
  • D-pad: directional arrows
  • Exit: Q or esc
  • A unit test suite tests the behaviour of the CPU using the nestest suite
  • It is regularly tested (manually) using the AccuracyCoin ROM.
Latest results

Do not be scared of the failing tests, please check out this video to understand what this ROM checks for.

Results from Oct. 11 2025

Screen.Recording.2025-10-11.at.17.56.24.mp4

This project wouldn't exist without the following resources. Many thanks to their respective authors 🙏

Why FuNes?

It's simple: Functional Programming + NES = FuNes

The fact that it shares the name with the late french actor Louis de Funes is accidental.

Read Entire Article