Added a comment about the includeStr "macro"

This commit is contained in:
Samuel Hammersberg 2023-01-24 11:43:54 +01:00
parent fd64a7e669
commit defe409d78

View file

@ -4,7 +4,12 @@ import Control.Monad
import Language.Haskell.TH
import System.IO.Unsafe(unsafePerformIO)
-- While this is hacky (specifically the use of unsafePerformIO)
-- in this case I think it is fine, as if an invalid string
-- is passed to the function it will fail to compile,
-- which is the intended behavior. This allows us to
-- import strings (such as our "standard LLVM library")
-- during compile time, removing the need to ship the source for
-- that with the compiler.
includeStr :: String -> Q Exp
includeStr file = do
let res = unsafePerformIO $ readFile file
[|res|]
includeStr file = [|unsafePerformIO $ readFile file|]