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
To: Simon Marlow
CC: Alex Jacobson ,
glasgow-haskell-users@haskell.org
References: <47434E64.1070206@alexjacobson.com>
<200711202239.57672.g9ks157k@acme.softbase.org>
<474354D4.7010307@alexjacobson.com> <4743F6B4.9050505@gmail.com>
<47447B2B.8090206@alexjacobson.com> <47454879.8040003@gmail.com>
Or use a preprocessor that inserts a LANGUAGE pragma. :)
On Nov 22, 2007 9:14 AM, Simon Marlow mailto:simonmarhaskell@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
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users