This file can be loaded into whatever editor you like to use for knitr. ghc is called for the second code block.
library(knitr)
opts_chunk$set(engine = "haskell", engine.path = "ghc")
: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() |]
[r| |]
)Also note a comment from here http://yihui.name/knitr/demo/engines/
:
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.