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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

Richard G.
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 <[hidden email]>
To: Simon Marlow <[hidden email]>
CC: Alex Jacobson <[hidden email]>,
[hidden email]
References: <[hidden email]>
<[hidden email]>
<[hidden email]> <[hidden email]>
<[hidden email]> <[hidden email]>



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

On Nov 22, 2007 9:14 AM, Simon Marlow <[hidden email]
<mailto:[hidden email]>> 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

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users