[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] Compilers

Subject: Re: [Haskell-cafe] Compilers
From: Gwern Branwen
Date: Sat, 16 Jan 2010 14:25:09 -0500
On Sat, Nov 29, 2008 at 8:02 PM, John Meacham <[email protected]> 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?
>> [email protected]:~/jhc/jhc-0.5.20080307> which DrIFT
>> /home/dafis/.cabal/bin/DrIFT
>> [email protected]:~/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.)

Haskell-Cafe mailing list
[email protected]

<Prev in Thread] Current Thread [Next in Thread>
  • Re: [Haskell-cafe] Compilers, Gwern Branwen <=