
4 Aug
2010
4 Aug
'10
3:05 a.m.
On 4 August 2010 07:42, Joachim Breitner
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 """ Cheers, Max