[Haskell-cafe] hsb2hs preprocessor looking for a maintainer

Max Bolingbroke batterseapower at hotmail.com
Wed Aug 4 03:05:03 EDT 2010

On 4 August 2010 07:42, Joachim Breitner <mail at joachim-breitner.de> wrote:
> out of a discussion in haskell-devscripts, John MacFarlane wrote a very
> nice tool, called hsb2hs, that allows you to include any binary (or
> text) file as a constant in your program.

When I've needed to do this in the past, I've used a simple bit of
Template Haskell:

module Embed where

import Language.Haskell.TH

embedFile :: String -> ExpQ
embedFile fp = runIO (readFile fp) >>= stringE

Here is how you use it to implement a (cheaty sort of) quine:

{-# LANGUAGE TemplateHaskell #-}
import Embed

foo = $(embedFile "UseEmbed.hs")

main = putStrLn foo


More information about the Haskell-Cafe mailing list