-
-
Save mtolly/265e41428d448049978d to your computer and use it in GitHub Desktop.
Sample Haskell project using embedded Ruby as a preprocessor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module A where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module B where | |
<% (1..5).each do |i| %> | |
test<%= i %> :: Int | |
test<%= i %> = <%= i %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ghctest | |
version: 0.1 | |
build-type: Custom | |
cabal-version: >= 1.10 | |
library | |
exposed-modules: A, B | |
build-depends: base | |
default-language: Haskell2010 | |
custom-setup | |
setup-depends: base, Cabal, process |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Distribution.Simple | |
import Distribution.Simple.PreProcess | |
import System.Process (readProcess) | |
runRuby _ _ = PreProcessor | |
{ platformIndependent = True | |
, runPreProcessor = mkSimplePreProcessor $ \erbFile fout verbosity -> do | |
readProcess "erb" [erbFile] "" >>= writeFile fout | |
} | |
main :: IO () | |
main = defaultMainWithHooks simpleUserHooks | |
{ hookedPreProcessors = [("erb", runRuby)] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment