[Haskell-cafe] Compilers

Gwern Branwen gwern0 at gmail.com
Sat Jan 16 14:25:09 EST 2010

On Sat, Nov 29, 2008 at 8:02 PM, John Meacham <john at repetae.net> wrote:
> On Sat, Nov 29, 2008 at 11:41:03PM +0100, Daniel Fischer wrote:
>> Great, nothing I don't already have, so download the source tarball, unpack
>> and
>> ./configure --prefix=$HOME
>> checking for a BSD-compatible install... /usr/bin/install -c
>> checking whether build environment is sane... yes
>> ... more configure output ...
>> checking for drift-ghc... no
>> configure: error:  DrIFT not found get it from
>> http://repetae.net/computer/haskell/DrIFT/
>> Huh?
>> dafis at linux:~/jhc/jhc-0.5.20080307> which DrIFT
>> /home/dafis/.cabal/bin/DrIFT
>> dafis at linux:~/jhc/jhc-0.5.20080307> DrIFT --version
>> Version DrIFT-2.2.3
> Oh golly. I never put DrIFT on cabal, apparently whomever tried to
> cabalize it didn't include the ghc driver script, and also appeared to
> just drop the documentation from the package altogether. It is things
> like that that make it very hard to get behind cabal, why was DrIFT
> crippled just so it can be put on cabal? If cabal wasn't powerful enough
> to compile DrIFT, and we already had a perfectly good way of compiling
> it, why the need to shoehorn it in and cause this problem? sigh.
>        John

Thought I'd mention that
http://hackage.haskell.org/package/DrIFT-cabalized includes a
drift-ghc.hs (compiles to /home/gwern/bin/bin/DrIFT-cabalized-ghc)
which is a clone of the drift-ghc.in shell script you allude to:

import Data.List (isInfixOf)
import System.Cmd (rawSystem)
import System.Environment (getArgs)
import System.Exit (ExitCode(ExitSuccess))
import Paths_DrIFT_cabalized  (getBinDir)

main :: IO ExitCode
main = do args <- getArgs
          case args of
            (a:b:c:[]) -> conditional a b c
            _ -> error "This is a driver script allowing DrIFT to be
used seamlessly with ghc.\n \
                       \ in order to use it, pass '-pgmF drift-ghc -F'
to ghc when compiling your programs."

conditional ::  FilePath -> FilePath -> FilePath -> IO ExitCode
conditional orgnl inf outf = do prefix <- getBinDir
                                infile <- readFile inf
                                if "{-!" `isInfixOf` infile then do
putStrLn (prefix ++ "DriFT-cabalized " ++

       inf ++ " -o " ++ outf)

rawSystem inf ["-o", outf]
                                 else do writeFile outf ("{-# LINE 1
\"" ++ orgnl ++ " #-}")
                                         readFile inf >>= appendFile outf
                                         return ExitSuccess
{- GHC docs say: "-pgmF cmd
   Use cmd as the pre-processor (with -F only).
Use -pgmF cmd  to select the program to use as the preprocessor.
When invoked, the cmd pre-processor is given at least three arguments
on its command-line:
1. the first argument is the name of the original source file,
2. the second is the name of the file holding the input
3. third is the name of the file where cmd should write its output to." -}

John: I would appreciate you pointing out if I have made a mistake
anywhere in that and not actually replicated the functionality of the
shell script. (I think I have, but I didn't really understand what the
first echo was supposed to do and just copied its functionality.)


More information about the Haskell-Cafe mailing list