# test 6 This file can be loaded into whatever editor you like to use for knitr. ghc is called for the second code block. ```{r engine='R'} library(knitr) opts_chunk$set(engine='haskell', engine.path='ghc') ``` ```{r engine='haskell'} :set -XQuasiQuotes :module +RlangQQ let fibs = 0.0:1: zipWith (+) fibs (drop 1 fibs) [r| png('test6_fig1.png'); plot(1:20, $(take 20 fibs)); dev.off() |] ``` ![test6 caption here](test6_fig1.png) ## limitations * This simple example works but unfortunately the haskell knitr engine doesn't allow newlines instead of semicolons in the quasiquote (`[r| |]`) * Also note a comment from here : Except engine='R' (default), all chunks are executed in separate sessions, so the variables cannot be directly shared. If we want to make use of objects created in previous chunks, we usually have to write them to files (as side effects). For the bash engine, we can use Sys.setenv() to export variables from R to bash (example). * Graphical output from haskell chunks has to be manually included.