* Unhealthy Haskell babel @ 2020-12-10 3:20 Lawrence Bottorff 2020-12-10 10:27 ` Immanuel Litzroth 2020-12-14 20:45 ` Bastien 0 siblings, 2 replies; 6+ messages in thread From: Lawrence Bottorff @ 2020-12-10 3:20 UTC (permalink / raw) To: emacs-orgmode Mailinglist [-- Attachment #1: Type: text/plain, Size: 1573 bytes --] 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 [-- Attachment #2: Type: text/html, Size: 1964 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Unhealthy Haskell babel 2020-12-10 3:20 Unhealthy Haskell babel Lawrence Bottorff @ 2020-12-10 10:27 ` Immanuel Litzroth 2020-12-10 17:21 ` Lawrence Bottorff 2020-12-14 20:45 ` Bastien 1 sibling, 1 reply; 6+ messages in thread From: Immanuel Litzroth @ 2020-12-10 10:27 UTC (permalink / raw) To: Lawrence Bottorff; +Cc: emacs-orgmode Mailinglist 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 <borgauf@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. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Unhealthy Haskell babel 2020-12-10 10:27 ` Immanuel Litzroth @ 2020-12-10 17:21 ` Lawrence Bottorff 2020-12-10 18:40 ` Immanuel Litzroth 0 siblings, 1 reply; 6+ messages in thread From: Lawrence Bottorff @ 2020-12-10 17:21 UTC (permalink / raw) To: Immanuel Litzroth; +Cc: emacs-orgmode Mailinglist [-- Attachment #1: Type: text/plain, Size: 3775 bytes --] I see your point, i.e., compiled, multi-file projects are not really meant for the REPL-dominant world of org-mode babel. Babel's sweet-spot would be the interpreted world, the very best probably a Lisp language. Still, the ability to add code to a running REPL should be possible. As I mentioned, SML is a sibling of Haskell and its babel implementation worked fine for me as I worked through an SML course. So yes, this appears to be a Haskell REPL issue. I'm just a beginner with Haskell, and all my intro texts start you out using the ghci REPL interactively. But then they switch you over to a text file compiled in the REPL with :l myfile.hs . . . no explanation as to why you can't just continue with the REPL putting the program in line-by-line. The fact that I can use the :set +m to include multiple lines of code, but cannot do a type definition is rather bizarre, though. This is a decision Haskell made with their REPL and babel really can't do much about it, I suppose. The Haskell .lhs literate option is interesting. Yes, I'd like to see your tangle option, please. On Thu, Dec 10, 2020 at 4:28 AM Immanuel Litzroth < immanuel.litzroth@gmail.com> wrote: > 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 <borgauf@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. > [-- Attachment #2: Type: text/html, Size: 4513 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Unhealthy Haskell babel 2020-12-10 17:21 ` Lawrence Bottorff @ 2020-12-10 18:40 ` Immanuel Litzroth 2020-12-10 20:26 ` Lawrence Bottorff 0 siblings, 1 reply; 6+ messages in thread From: Immanuel Litzroth @ 2020-12-10 18:40 UTC (permalink / raw) To: Lawrence Bottorff; +Cc: emacs-orgmode Mailinglist Well another possible solution is to wrap the code blocks in :{ xxx :} in (defun org-babel-execute:haskell (body params) -- ob-haskell.el Immanuel On Thu, Dec 10, 2020 at 6:21 PM Lawrence Bottorff <borgauf@gmail.com> wrote: > > I see your point, i.e., compiled, multi-file projects are not really meant for the REPL-dominant world of org-mode babel. Babel's sweet-spot would be the interpreted world, the very best probably a Lisp language. Still, the ability to add code to a running REPL should be possible. As I mentioned, SML is a sibling of Haskell and its babel implementation worked fine for me as I worked through an SML course. So yes, this appears to be a Haskell REPL issue. I'm just a beginner with Haskell, and all my intro texts start you out using the ghci REPL interactively. But then they switch you over to a text file compiled in the REPL with :l myfile.hs . . . no explanation as to why you can't just continue with the REPL putting the program in line-by-line. The fact that I can use the :set +m to include multiple lines of code, but cannot do a type definition is rather bizarre, though. This is a decision Haskell made with their REPL and babel really can't do much about it, I suppose. The Haskell .lhs literate option is interesting. Yes, I'd like to see your tangle option, please. > > On Thu, Dec 10, 2020 at 4:28 AM Immanuel Litzroth <immanuel.litzroth@gmail.com> wrote: >> >> 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 <borgauf@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. -- -- Researching the dual problem of finding the function that has a given point as fixpoint. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Unhealthy Haskell babel 2020-12-10 18:40 ` Immanuel Litzroth @ 2020-12-10 20:26 ` Lawrence Bottorff 0 siblings, 0 replies; 6+ messages in thread From: Lawrence Bottorff @ 2020-12-10 20:26 UTC (permalink / raw) To: Immanuel Litzroth; +Cc: emacs-orgmode Mailinglist [-- Attachment #1: Type: text/plain, Size: 4815 bytes --] Yes -- and I think I came across this long ago during another attempt and totally forgot about it. I think I'll write this up on emacs.stackexchange so others will not have to scrounge around. I'm pursuing this because I really believe emacs org-mode "reproducible research" is superior to all other methods so far. On Thu, Dec 10, 2020 at 12:40 PM Immanuel Litzroth < immanuel.litzroth@gmail.com> wrote: > Well another possible solution is to wrap the code blocks in > :{ > xxx > :} > in > (defun org-babel-execute:haskell (body params) -- ob-haskell.el > Immanuel > > On Thu, Dec 10, 2020 at 6:21 PM Lawrence Bottorff <borgauf@gmail.com> > wrote: > > > > I see your point, i.e., compiled, multi-file projects are not really > meant for the REPL-dominant world of org-mode babel. Babel's sweet-spot > would be the interpreted world, the very best probably a Lisp language. > Still, the ability to add code to a running REPL should be possible. As I > mentioned, SML is a sibling of Haskell and its babel implementation worked > fine for me as I worked through an SML course. So yes, this appears to be a > Haskell REPL issue. I'm just a beginner with Haskell, and all my intro > texts start you out using the ghci REPL interactively. But then they switch > you over to a text file compiled in the REPL with :l myfile.hs . . . no > explanation as to why you can't just continue with the REPL putting the > program in line-by-line. The fact that I can use the :set +m to include > multiple lines of code, but cannot do a type definition is rather bizarre, > though. This is a decision Haskell made with their REPL and babel really > can't do much about it, I suppose. The Haskell .lhs literate option is > interesting. Yes, I'd like to see your tangle option, please. > > > > On Thu, Dec 10, 2020 at 4:28 AM Immanuel Litzroth < > immanuel.litzroth@gmail.com> wrote: > >> > >> 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 <borgauf@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. > > > > -- > -- Researching the dual problem of finding the function that has a > given point as fixpoint. > [-- Attachment #2: Type: text/html, Size: 6106 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Unhealthy Haskell babel 2020-12-10 3:20 Unhealthy Haskell babel Lawrence Bottorff 2020-12-10 10:27 ` Immanuel Litzroth @ 2020-12-14 20:45 ` Bastien 1 sibling, 0 replies; 6+ messages in thread From: Bastien @ 2020-12-14 20:45 UTC (permalink / raw) To: Lawrence Bottorff; +Cc: emacs-orgmode Mailinglist Hi Lawrence, Lawrence Bottorff <borgauf@gmail.com> writes: > I'm looking into Haskell (latest ghci) again on org-mode. This Sadly enough, we don't have a maintainer for ob-haskell.el. Would you be willing to become the maintainer? Of course, you can always hand it over to someone else when you want to. It is just better to have someone than to have no one. Best, -- Bastien ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-12-14 20:51 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-12-10 3:20 Unhealthy Haskell babel Lawrence Bottorff 2020-12-10 10:27 ` Immanuel Litzroth 2020-12-10 17:21 ` Lawrence Bottorff 2020-12-10 18:40 ` Immanuel Litzroth 2020-12-10 20:26 ` Lawrence Bottorff 2020-12-14 20:45 ` Bastien
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).