[Fwd: Re: suggestion: add a .ehs file type]

Richard Giraud richardg at richardg.name
Thu Nov 22 07:08:23 EST 2007


A pre-processor is a great idea.  Template Haskell and Cabal make it 
possible to extend the language by adding all kinds of funky 
pre-processing (via Cabal hooks) and compile-time calculations.  It 
wouldn't be too difficult to add a package-specific .ehs file type with 
the desired behavior.

I'm currently using this combo to work around the TH limitation of not 
being able to generate import statements.  A Cabal hook looks in a 
directory to find what .hs files are present, spits out an intermediate 
file that imports all of these files, and Cabal compiles the generated 
file into the final program.

I think that the biggest limitation of this setup is managing the files 
if multiple stages of pre-processing are performed.

Richard

-------- Original Message --------
Subject: 	Re: suggestion: add a .ehs file type
Date: 	Thu, 22 Nov 2007 10:19:57 +0000
From: 	Lennart Augustsson <lennart at augustsson.net>
To: 	Simon Marlow <simonmarhaskell at gmail.com>
CC: 	Alex Jacobson <alex at alexjacobson.com>,
glasgow-haskell-users at haskell.org
References: 	<47434E64.1070206 at alexjacobson.com>
<200711202239.57672.g9ks157k at acme.softbase.org>
<474354D4.7010307 at alexjacobson.com> <4743F6B4.9050505 at gmail.com>
<47447B2B.8090206 at alexjacobson.com> <47454879.8040003 at gmail.com>



Or use a preprocessor that inserts a LANGUAGE pragma. :)

On Nov 22, 2007 9:14 AM, Simon Marlow <simonmarhaskell at gmail.com
<mailto:simonmarhaskell at gmail.com>> wrote:

     Alex Jacobson wrote:

      > In any case, I'm pretty sure the correct answer is not 50 language
      > pragmas with arbitrary spellings for various language features 
at the
      > top of each source file.

     You probably won't like any of these, but there are many ways to avoid
     writing out all the pragmas at the top of each file.

     1. Use Cabal's extensions field.

     2. Use CPP

     MyExtensions.h :
     {-# LANGUAGE TemplateHaskell, FlexibleInstances,
                  OverlappingInstances, UndecidableInstances, CPP,
                  ScopedTypeVariables, PatternSignatures, GADTs,
                  PolymorphicComponents, FlexibleContexts,
                  MultiParamTypeClasses, DeriveDataTypeable,
                  PatternGuards #-}

     MyModule.hs:
     {-# LANGUAGE CPP #-}
     #include "MyExtensions.h"

     3. Use a shell alias

     alias ghce='ghc -XTemplateHaskell -XFlexibleInstances ...'

     4. use a script wrapper for GHC

     #!/bin/sh
     exec ghc -XTemplateHaskell -XFlexibleInstances ... $*

     I'm sure there are more...

     Cheers,
            Simon
-------------- next part --------------
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users at haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



More information about the Glasgow-haskell-users mailing list