[Haskell-cafe] Windows console

Andrew Coppin andrewcoppin at btinternet.com
Sat Sep 13 08:41:17 EDT 2008


Max Bolingbroke wrote:
> 2008/9/13 Andrew Coppin <andrewcoppin at btinternet.com>:
>   
>>> Just FYI, I have now implemented and tested this feature. The new
>>> version, 0.5.0, is available on Hackage.
>>>       
>> For both platforms?
>>     
>
> Of course! My package promises to work cross-platform, after all.
>   

[rejoyce!]

>> Out of interest, how do you get the correct package built on each platform?
>>     
>
> If you mean "how do I compile the ANSI emulator on Windows but the
> actual ANSI stuff on Unix", most of the magic is in the .cabal file:

> I simply turn on the C-preprocessor (CPP) and then supply -DWINDOWS on
> Windows and -DUNIX on anything else. The actual use of CPP in my
> source is then confined to a single module
> which either imports System.Console.ANSI.Windows or
> System.Console.ANSI.Unix depending on which of those two have been
> defined.
>
> Nothing to it, really. However, this is the stuff that is making the
> Hackage documentation generation choke currently because until
> recently Cabal forgot to supply the CPP flags to a Haddock 2 (but not
> Haddock 0.x) run.
>   

Hmm, I wasn't aware you could use the C preprocessor on Haskell source 
code. That could be rather useful, e.g., for adding or removing debug code.

Anyway, that still leaves one question: how do you figure out which 
platform you're on so you can set the right options?



More information about the Haskell-Cafe mailing list