Same as test6, except needs a change to knitr as of October 2013 (ie. 1.5 is not good enough). This commit is needed.
This file can be loaded into whatever editor you like to use for knitr. I use vim-r-plugin, but perhaps ESS or Rstudio can also work. After some set-up in the first block. ghc is called for the second code block.
library(knitr)
opts_chunk$set(engine = "haskell", engine.path = "ghc", engine.opts = "-e \":set -XQuasiQuotes\" -e \"import RlangQQ\"")
let fibs = 0.0:1: zipWith (+) fibs (drop 1 fibs)
[r| png('test6_fig1.png')
plot(1:20, $(take 20 fibs))
dev.off() |]
do let x = 1
print(1+x)
print(2+x)
## 2
## 3
each block is a separate session. You would have to manually save/load variables defined in the previous chunk to make things work as they do for R.
code is interpreted, not compiled
graphical output from haskell chunks has to be manually included
See here