Which is the most "hackable" compiler?

So I have some crazy ideas for language extensions/reinterpretations and ways I might try to implement them. But ghc is a complex beast and my crazy ideas have too many interrelationships for a noob like me to try to bold them onto it. After all, I have never worked on ghc - or any compiler for that matter. I did look at the code, but I reckon maybe I should gather some experience first before diving into that one. It would be even worse to offload my ideas onto someone else before I at least tried them and got some feedback. No fun for anyone. But of course I don't want to start from scratch. As fun as that could be, there's no need to reinvent all the wheels just for a different axle. And I hear rumors that there are other Haskell compilers out there, even if most of them live in the shadow/slipstream of their brother. Alas, I don't have any idea what their statuses and philosophies are. So maybe you can help me here: Have you experienced any of the alternative compilers as especially easy for a newcomer to pick up and play around with? If it helps, I would be satisfied with plain Haskell2010 or even Haskell 98, although some GADT and/or TypeFamilies code to butcher would be nice, too. The ideas are mostly about larger scale structures like whole functions. One representative example idea is "Could it help the implementation - and does it even make sense - to view a module as just a weirdly written zero parameter type class?" As I said: crazy ideas. I'm thankful for any thoughts and ideas. MarLinn

You should go for a long run with GHC, it has most advanced extension system and you'll be able to integrate your extensions with existing codebase if they come out successful. If you still want to work with hackablel compiler look at jhc https://github.com/jimcrayne/jhc and it's fork ajhc https://github.com/ajhc/ajhc they are very low-level but codebase very small and you can grasp whole system very quickly to start hacking On 08/12/2016 10:58 PM, MarLinn via Haskell-Cafe wrote:
So I have some crazy ideas for language extensions/reinterpretations and ways I might try to implement them. But ghc is a complex beast and my crazy ideas have too many interrelationships for a noob like me to try to bold them onto it. After all, I have never worked on ghc - or any compiler for that matter. I did look at the code, but I reckon maybe I should gather some experience first before diving into that one. It would be even worse to offload my ideas onto someone else before I at least tried them and got some feedback. No fun for anyone.
But of course I don't want to start from scratch. As fun as that could be, there's no need to reinvent all the wheels just for a different axle. And I hear rumors that there are other Haskell compilers out there, even if most of them live in the shadow/slipstream of their brother. Alas, I don't have any idea what their statuses and philosophies are.
So maybe you can help me here: Have you experienced any of the alternative compilers as especially easy for a newcomer to pick up and play around with? If it helps, I would be satisfied with plain Haskell2010 or even Haskell 98, although some GADT and/or TypeFamilies code to butcher would be nice, too. The ideas are mostly about larger scale structures like whole functions. One representative example idea is "Could it help the implementation - and does it even make sense - to view a module as just a weirdly written zero parameter type class?" As I said: crazy ideas.
I'm thankful for any thoughts and ideas.
MarLinn
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

On 13 Aug 2016, at 5:58 AM, MarLinn via Haskell-Cafe
wrote: So maybe you can help me here: Have you experienced any of the alternative compilers as especially easy for a newcomer to pick up and play around with? If it helps, I would be satisfied with plain Haskell2010 or even Haskell 98, although some GADT and/or TypeFamilies code to butcher would be nice, too. The ideas are mostly about larger scale structures like whole functions.
You might want to check out DDC [1]. It’s still in a pre-alpha state, but what it does have is a working external core language. You could write your own front end that produces System-F, then have DDC compile that. The individual compiler passes are also fairly well separated, so it’s easy to change.
One representative example idea is "Could it help the implementation - and does it even make sense - to view a module as just a weirdly written zero parameter type class?" As I said: crazy ideas.
This is perfectly reasonable. I think Agda does something similar. Ben. [1] http://disciple.ouroborus.net/ http://disciple.ouroborus.net/

GHC compiler plugins may also be what you're looking for. Also, does ghc not compile core files anymore? It used to; you can always use an older ghc version. Tom
El 13 ago 2016, a las 20:20, Ben Lippmeier
escribió: On 13 Aug 2016, at 5:58 AM, MarLinn via Haskell-Cafe
wrote: So maybe you can help me here: Have you experienced any of the alternative compilers as especially easy for a newcomer to pick up and play around with? If it helps, I would be satisfied with plain Haskell2010 or even Haskell 98, although some GADT and/or TypeFamilies code to butcher would be nice, too. The ideas are mostly about larger scale structures like whole functions.
You might want to check out DDC [1]. It’s still in a pre-alpha state, but what it does have is a working external core language. You could write your own front end that produces System-F, then have DDC compile that. The individual compiler passes are also fairly well separated, so it’s easy to change.
One representative example idea is "Could it help the implementation - and does it even make sense - to view a module as just a weirdly written zero parameter type class?" As I said: crazy ideas.
This is perfectly reasonable. I think Agda does something similar.
Ben.
[1] http://disciple.ouroborus.net/
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

On 14 Aug 2016, at 12:53 PM, amindfv@gmail.com wrote:
GHC compiler plugins may also be what you're looking for.
Also, does ghc not compile core files anymore? It used to; you can always use an older ghc version.
IIRC GHC once could produce external core files, but it was never able to parse them back. The support rotted, so it was removed a few years ago. The way GHC is engineered makes it difficult/impossible for core-to-core plugins to introduce names into the core file that were not already present. Plugins can *rearrange* code that contains existing identifiers, but once the front-end type checker/desugarer is finished there isn’t an easy way to load more interface files to get at other names of things. This was the state of GHC in 2013 when I was working on the Repa plugin [1], it might have changed since then. Ben. [1] https://hackage.haskell.org/package/repa-plugin https://hackage.haskell.org/package/repa-plugin

Thank you all very much for your tips! @Ben
You might want to check out DDC [1]. It’s still in a pre-alpha state, but what it does have is a working external core language. You could write your own front end that produces System-F, then have DDC compile that. The individual compiler passes are also fairly well separated, so it’s easy to change.
DDC looks like quite interesting, but I don't think it is what I am looking for. For one thing the first parsing step is something I would prefer to "steal" wholesale, and I would also like to avoid messing with the type system where I'm not abusing it. On the other hand the claim that its purpose is to "investigate program transformation" sounds promising and I love how the code is littered with comments. So I will definitely look at it more closely, even if it's only to learn some tricks. @Sergey
If you still want to work with hackablel compiler look at jhc https://github.com/jimcrayne/jhc and it's fork ajhc https://github.com/ajhc/ajhc
JHC immediately got my +1 because they have a rough diagram of the core transformations (http://repetae.net/computer/jhc/big-picture.pdf). It's far from perfect, but as a visual learner I love such stuff and would like other complex programs to offer something similar. It also looks like there might be some shared code between JHC and UHC? Speaking of the latter, that one looks well documented, too. So both might be a good place to start. @Tom
GHC compiler plugins may also be what you're looking for.
Funnily enough GHC plugins are one of the reasons I'm shying away from GHC at the moment. Not that it's a bad idea, especially for optimizations. But focusing so much on one core structure (no pun intended) leads to a lot of dependencies on that structure and makes it hard to change it. At the same time I don't think such a linear pipeline approach is necessarily the best one. Say we want to implement a prolog-like sublanguage, makros, or even externalized typesystems at some point, as other languages are doing. (with makros serving as a core tool to keep all these kitchen sinks optional) The easiest approach would be to create separate branching paths in the compiler. Which in turn might be implemented by a DAG of independent transformer modules with separate pre- and postconditions, flexible intermediate types and semi-automatic dependency resolution. In other words tight integration with a powerful build system. That doesn't sound like something I will be able to offer, but I think it would be a good idea to at least experiment with approaches that might lead in that direction instead of relying on one core highway. Which lead me to the conclusion... @Sergey
You should go for a long run with GHC, it has most advanced extension system and you'll be able to integrate your extensions with existing codebase if they come out successful.
...that while that is certainly "the one true way to go" later, it's not the place I want to start at. Sorry, GHC. You will still be my build tool of choice, though. So for now my takeaway is that I will start by looking at UHC and JHC as possible places to start. DDC might be able to contribute parts or ideas. And if everything is too complicated I might just rip out parts from different projects and throw together my own minimalistic frankencompiler. So again, thanks for your contributions. It will probably take a long time for any significant results, but I'll keep you posted. Cheers, MarLinn
participants (4)
-
amindfv@gmail.com
-
Ben Lippmeier
-
MarLinn
-
Sergey Bushnyak