How do you design a CPU for functional languages like Haskell?

Use a stackmachine where the function referenced by each head is popped with a given number of arguments copying the referenced function body into its place on the stack with argument references replaced & relative references resolved.

Opcodes are added for arithmatic, with ints shuffling the stack to ensure they're fully resolved before the arithmatic.

This has been prototyped on FPGAs!


There has been refinements made to this "Reduceron" design to optimize pattern matching, said arithmatic, & more! But that's the basic concept.

And yes, there's caching of lazily-computed values & a builtin (stop-the-world) GC.

I imagine that if programs get large enough to require prefetching, the stack would make that trivial! Though compiler optimizations would still be useful to achieve good memory locality.

2/2 Any Lispers want to chime in? you know what, i'm just going to add another field to my profile linking it 🤷‍♂️

Sign in to participate in the conversation

For people who care about, support, or build Free, Libre, and Open Source Software (FLOSS).