Haskell programming constructs you must know to contribute to a production system?

Hello, what are the programming constructs you must know to be able to contribute to a production 30 kloc compiler written in Haskell?

I need to get ready for an interview. I have two months. I already have experience writing functional code. I have experience writing functional code in Lisp so I am familiar with the way of thinking.

Thanks

I guess you could start by exploring existing OSS compilers (Idris 1, Agda, Elm, purescript, …)

I don’t think there is much arcane Haskell involved.

IMHO Haskell will not be the biggest challenge - getting to know the big project and probably everything related to compiler development will be.

So I guess it depends on your experience in this fields.
Maybe even having a look at Write yourself a Scheme in 48 hours could be beneficial to you (caution: the Wiki-book does not make the best recommendations when installing Haskell tooling and project setup is involved - not sure if there is a more current version out there sorry)

2 Likes

You should be comfortable with using Monad Transformers.

2 Likes

I’ve worked on two non-trivial language implementations in Haskell (Idris 1 and Cryptol).

In addition to monad transformers, as @Kleidukos mentioned, I would also make sure to be aware of the differences between and use cases for String vs ByteString vs Text. It would be useful to have experience with parsing technology (Happy/Alex and/or Megaparsec) and a pretty-printing library. Depending on the architecture of the compiler, you may need to know how to write concurrent systems - for this, Simon Marlow’s book is excellent. Finally, you should understand GHC’s exceptions mechanism, and how to catch exceptions in IO. Aside from this, I don’t think there’s much Haskell-specific going on in a language implementation, and it would be more important to study up on things like type checking algorithms, code generation techniques, intermediate representations, and static analysis. These fundamentals are not Haskell-specific, but they are likely to be relevant for a language implementation job, depending on the specifics of the language in question.

5 Likes

When is String ever useful? I thought it was the idea of string as linked list which end up more harmful than useful.

1 Like

It’s really nice to learn Haskell/FP as you have a nice day-to-day example of lists and it’s nice to deal with strings as lists of characters in exercise-algorithms.
I think it was the obvious translation of old-style ASCII-strings as “arrays of char” into FP land with List instead of Array.

Take Advent-of-Code for example - I really don’t want to mess with Text there :wink:

1 Like

It’s usually not the right representation for text strings for serious applications. But it is in the Prelude, and for historical reasons it often forms a kind of glue (e.g. in class IsString), and it sometimes is the easiest thing in a context where the other properties are not so important.

2 Likes