This article is a translation of Chris Hodapp's post Embedding Haskell: Compilers, and compiling compilers In this post, the author explores various approaches to using Haskell to write code for embedded systems. Let's give the floor to the author.
In my last post , it was mentioned that some things require a better explanation because I am always trying to explain and clarify.
This blog is about using Haskell with embedded systems. What does that even mean? We see a couple of broad categories (which reflect the slides on the last page as well as our links page ):
- Full compilation: compiles Haskell code for an inline assignment.
- Limited compilation: Compilation of some limited subset of Haskell code for an inline purpose.
- EDSL and Compiler Hosting: Hosting in Haskell, EDSL and compiler for embedded use.
As far as I know, I came up with these categories. If someone knows a more established classification, more appropriate names or examples of the one who wrote about it first, please let me know.
It might look like one-sided, arbitrary grouping; it's kind of like that. The generality is that in all cases Haskell is used to express something (programs, schemas, specifications, call it what you will) for an inline purpose. More on this later.
I exclude things like Cryptol and Idris because, being implemented in Haskell and suitable for embedded platforms, they are different languages themselves. I can arbitrarily drop this distinction in the future if I wish ...
Complete compilation
, , Haskell — Haskell , ( , ). Compiling to Embedded Targets .
, . Haskell . , Haskell .
Ajhc, , JHC, Kiwamu Okabe METASEPI, , — ARM Cortex-M3 / M4. Kiwamu Haskell . ATS .
HaLVM Galois, , .
( ), , . (, , , : CλaSH Haskell).
EDSL
Code Generation EDSLs Circuit Design EDSLs . , , .
. EDSL (Embedded Domain-Specific Language, - ) Haskell, . .
: , , Haskell. Haskell — . , .
:
:
- Haskell, , ( ). , , .
- . , Copilot / , SBV , Atom .
, Haskell . , , , .
, , , , .
:
- «» Haskell , - ( , , main).
- Atom , Atom ( , , Atom).
- Ivory , Ivory eff
Module ( , Ivory). - CλaSH Signal ( , , topEntity).
? (, . , , Lava .)
. ( ), Haskell. , :
- ,
- ( Haskell, - , , ),
- ( , LLVM, C, VHDL, , ..).
«» Haskell.
, Haskell - . Haskell, .