Skip to content

Instantly share code, notes, and snippets.

@mtolly
Created July 15, 2015 18:06
Show Gist options
  • Save mtolly/265e41428d448049978d to your computer and use it in GitHub Desktop.
Save mtolly/265e41428d448049978d to your computer and use it in GitHub Desktop.
Sample Haskell project using embedded Ruby as a preprocessor
module A where
module B where
<% (1..5).each do |i| %>
test<%= i %> :: Int
test<%= i %> = <%= i %>
<% end %>
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
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