Org-babel for haskell does not work eval haskell block

I use the org-mode blog, I use org-babel to evaluate the code as follows:

#+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 that org-babel for haskell uses infer-haskell mode to start a session and eval code. I also say that the session was created, and if I do not define the function, but directly put "hello" putStrLn, it works.

hope anyone can fix the error :)

+4
source share
2 answers
#+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 Babel mode runs Haskell code with ghci. In ghci, you should use let to declare functions.

+2
source

All Articles