[Haskell-cafe] More on the random idea

Andrew Coppin andrewcoppin at btinternet.com
Sat May 26 15:12:13 EDT 2007


Neil Mitchell wrote:
> HI
>
>> For me, the unfortunate thing is that there seems to be no interpreter
>> for Haskell written in Haskell. (Except for GHC, which is *huge*.)
>
> What do you mean by *huge*? Takes up to much memory at runtime?
> Requires too long to compile? Has had too many experts spending lots
> of time writing it? A large volume of source code isn't a negative,
> unless you are expected to do something with it that involves
> modifying a large chunk of it.

It's too large and complicated to use for small things. E.g., if you 
want to just dash off a little something that needs to evaluate an 
expression... Well, you can use the GHC API. But this is highly 
nontrivial. You get the impression it was added later, and the internal 
structure of GHC is so complex that it makes it hard to write a 
lightweight interface to it.

>> We have a Haskell parser [which is complex beyond usability]
>
> Which takes a Haskell file and produces an abstract syntax tree
> representing Haskell? I'm not sure how that's complex, it does exactly
> what it says on the tin - it parses Haskell.

First, there is the minor point that you can't parse a Haskell 
expression - only an entire Haskell module. Then we come to the real 
problem: Sure, it parses Haskell. Into a *giant* data structure that 
could take many decades to map out. And that's because it keeps every 
minute detail of the original source. For example, the expressions "1 + 
1" and "(+) 1 1" parse differently and give different trees, despite 
representing the exact same language construct.

I want an *abstract* tree, that just represents the semantics of the 
expression, not every minute syntactic detail. (Although the latter 
might be useful in other contexts - syntax hilighting perhaps.)

>> them find it doesn't implement Haskell precisely. So it looks like I'm
>> stuck with present technology - and that essentially means GHC. (Other
>> compilers? What other compilers??)
>
> Yhc, Hugs, JHC...

I don't know about Linux, but Hugs is currently hopelessly unstable on 
Windoze. As for the others... I've not used them, but the Haskell Wiki 
makes it sound like they're all immature research projects rather than 
end-user usable compilers. (I don't know how true that is.)

>> As far as I know, hs-plugins works by taking an expression, writing it
>> to a file, calling GHC to parse it, transform it to Core, optimise it,
>> transform it to STG, optimise it, transform it to C--, optimise it,
>> transform it to ANSI C, optimise it, pass it to GCC, compile it, link
>> it, and *then* using the GHC runtime linker to load the generated object
>> code into memory, type-check it, and, finally, execute it.
>
> Are you complaining that this process is too slow? Complaints about
> speed should take the form "I expected this to happen in 3 seconds, it
> requires 12". You can't have a complaint about it doing clever things
> automatically for you, only that the results of those clever things
> don't meet your needs.

It just seems vastly overkill to generate native executable code for 
something you only want to execute once, which is probably only going to 
take a fraction of a second anyway.

>> Whatever... I'd just like to see an online way to run Haskell, and since
>> the Lambdabot webpage still shows no sign of working...
>
> Writing a Haskell interpreter seems like a lot of work, if all you
> want is "a few tweaks to lambdabot". Of course, a Haskell interpreter
> is something I'd love to see :)

Well, we'll see. I keep telling people I'm going to write a Haskell to 
Java compiler, and yet no code ever seems to get written... *sigh*



More information about the Haskell-Cafe mailing list