I don't think org-babel is a good fit for compiled languages. If the idea is to just take 1 snippet, and "execute" that it means that to have a consistent whole you'd need to put all the modules of your program into that snippet (already impossible in Haskell, you can have only 1 module per file), compile that, run the resulting binary. Or org mode would have to have some idea of what needs to be retangled & rebuilt. I think that using org-babel for compiled, multifile languages will only work in very simple cases -- and even then.. -- but will lead to problems very soon. Immanuel
On Thu, Dec 10, 2020 at 4:21 AM Lawrence Bottorff <borg...@gmail.com> wrote: > > I'm looking into Haskell (latest ghci) again on org-mode. This > > #+begin_src haskell :results verbatim :exports both > :set +m > doubleSmallNumber x = if x > 100 > then x > else x*2 > #+end_src > > works, but still the :set +m is necessary for it to see the whole. But this > > #+begin_src haskell :results verbatim :exports both > :set +m > factorial :: Int -> Int > factorial 0 = 1 > factorial n = n * factorial (n - 1) > #+end_src > > results in this on the REPL side: > > Prelude> :set +m > factorial :: Int -> Int > factorial 0 = 1 > factorial n = n * factorial (n - 1) > "org-babel-haskell-eoe" > Prelude> > <interactive>:26:1-23: error: > • No instance for (Show (Int -> Int)) arising from a use of ‘print’ > (maybe you haven't applied a function to enough arguments?) > • In a stmt of an interactive GHCi command: print it > Prelude> Prelude> Prelude> "org-babel-haskell-eoe" > > which is the same behavior if I try to feed the program into the REPL one > line at a time, i.e., > > Prelude> factorial :: Int -> Int > > <interactive>:40:1-23: error: > • No instance for (Show (Int -> Int)) arising from a use of ‘print’ > (maybe you haven't applied a function to enough arguments?) > • In a stmt of an interactive GHCi command: print it > > So the :set +m trick (take multiple lines) doesn't help here. Obviously, > Haskell is not ready to be used with Babel. Can it be fixed? BTW, this does > work with the regular ghci REPL and haskell-mode. If it helps, Standard ML, > which has very similar syntax (it was Haskell's parent), works fine. > > LB -- -- Researching the dual problem of finding the function that has a given point as fixpoint.