From defe409d78433b322c83842b060c15c2063e7f5a Mon Sep 17 00:00:00 2001 From: Samuel Hammersberg Date: Tue, 24 Jan 2023 11:43:54 +0100 Subject: [PATCH] Added a comment about the includeStr "macro" --- src/Compiler/TH.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Compiler/TH.hs b/src/Compiler/TH.hs index 497cbc7..bfa9277 100644 --- a/src/Compiler/TH.hs +++ b/src/Compiler/TH.hs @@ -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|] \ No newline at end of file +includeStr file = [|unsafePerformIO $ readFile file|] \ No newline at end of file