Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org-babel for haskell not works of eval haskell block

I am use org-mode blogging, I use org-babel to evaluate the code as following :

#+BEGIN_SRC haskell
import Data.Function (fix)

f :: Int -> Int
f = (+ 1)

main :: IO ()
main = do
      putStrLn $ show $ f 1
#+END_SRC

#+RESULTS:
: <interactive>:9:25: Not in scope: ‘f’

I found the org-babel for haskell use infer-haskell mode to start session and eval the code. I also say the session was created, and if I don't define the function but directly putStrLn "hello" , it works.

hope anyone can fix the bug :)

like image 646
Chinaxing Avatar asked Mar 08 '15 14:03

Chinaxing


2 Answers

In this article, Yoshinari Nomura describes a way to evaluate Haskell blocks using runhaskell via a Ruby script. I do not understand japanese, so I cannot translate the details, but the method has allowed me to run haskell blocks without having to write specifically for the interpreter.

like image 148
Mario Román Avatar answered Nov 04 '22 07:11

Mario Román


#+BEGIN_SRC haskell
import Data.Function (fix)

f :: Int -> Int
let f = (+ 1)

main :: IO ()
main = do
      putStrLn $ show $ f 1
#+END_SRC

#+RESULTS:
: 2

Org's babel mode is running the Haskell code with ghci. In ghci you are required to use let to declare functions.

like image 3
codygman Avatar answered Nov 04 '22 07:11

codygman