Skip to content

Commit

Permalink
Make rgraph quasiquoter print the result.
Browse files Browse the repository at this point in the history
This is useful for graphical packages like ggplot2.
  • Loading branch information
mboes committed Aug 14, 2015
1 parent 2bbcb6c commit 9b46f0d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions IHaskell/src/IHaskell/Display/InlineR.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ import Language.Haskell.TH.Quote
import System.Directory

rprint :: QuasiQuoter
rprint = QuasiQuoter { quoteExp = \s -> [| do result <- $(quoteExp r s)
H.print result |] }
rprint = QuasiQuoter { quoteExp = \s -> [| do H.p $(quoteExp r s) |] }

rgraph :: QuasiQuoter
rgraph = QuasiQuoter { quoteExp = \s ->
[| do idx <- findMaxIndex 0
let fname = mkName idx
_ <- [r| png(filename=fname_hs, width=480, height=480, bg="white"); |]
_ <- $(quoteExp r s)
H.p $(quoteExp r s)
_ <- [r| dev.off() |]
encoded <- Base64.encode <$> B.readFile fname
display $ BH.img BH.! BH.src
Expand Down

0 comments on commit 9b46f0d

Please sign in to comment.