emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Babel woes
@ 2011-08-17 12:59 Andras Major
  2011-08-17 13:51 ` Sebastien Vauban
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andras Major @ 2011-08-17 12:59 UTC (permalink / raw)
  To: emacs-orgmode

Hi everyone,

I've been trying to use org-mode for report generation lately, and
haven't really succeeded. Here's a list of issues I encounter:

- Babel offers a way of generating a code block from the output or
  value of a code block.  That new block, however, is forced to the
  same language as the original block -- that is doesn't allow me, for
  example, to use a Haskell block to create an asymptote figure which
  then generates an image in the HTML or PDF export version.  Is there
  a way around this limitation?

- Ruby: is inf-ruby really required? Why can't I execute a ruby block
  without it?

- Haskell: there are at least two interpreters that babel will invoke,
  depending on what is available (ghci and hugs), and those two are
  incompatible in some areas (such as loading modules, where the
  commands are different -- :add vs. :load). I haven't found a way of
  + forcing the use of a specific interpreter;
  + specifying command-line arguments to the interpreter (which would
    eliminate the need for :add or :load).
  This really makes using Haskell rather hit-and-miss, see below.

- Haskell code usage is rather cumbersome: since Babel invokes an
  interpreter rather than runghc, a Haskell block doesn't nearly have
  the flexibility of a real Haskell program.  In particular, one can
  only make definitions (portably) in the Haskell code by creating a
  separate block which is tangled but not executed.  Another block,
  which is executed, can then load the tangled module and use its
  definitions (if it weren't for the problems described above and
  below).

- The handling of interpreted Haskell appears to be rather dodgy: If I
  want to load a module (in ghci) and then evaluate some function,
  then I run into real trouble.  None of my tests run at all when
  first loaded into emacs, but if I execute some tests in a certain
  order, it all starts working.  I haven't been able to figure out yet
  what goes wrong and what "playing around" makes things work, but it
  appears that
#+begin_src haskell
  :add SomeModule
  someFunction
#+end_src
  will not work because the :add statement is ignored. If I put the
  two lines in separate Haskell blocks and execute each one
  separately, then things start to work.

- I also tried using sbe to invoke a Haskell function from within a
  table formula.  Here I usually get an error "ERROR - Undefined
  variable "x"", which sometimes goes away rather magically (I'm not
  sure what makes it go away), after which things work just fine.
  Emacs-lisp blocks written in the same manner work out of the box.

- Haskell uses a static type system, and there is no such thing as
  automatic casting if a variable has the wrong type for a given
  function.  Thus, if I evaluate the numbers of a table using Haskell
  and sbe, and some values have a decimal dot and other (integer) ones
  omit it, then one of these versions will throw an error.  Is there a
  way of converting the values beforehand to a given type (say,
  Double), only to make Haskell happy?

Can anyone give me a hint of why these things don't work and whether
I'm doing something wrong?

Oh, I'm using emacs from Debian testing (23.2+1-7) and org from git
(cloned today).

Thanks,

  András

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Babel woes
  2011-08-17 12:59 Babel woes Andras Major
@ 2011-08-17 13:51 ` Sebastien Vauban
  2011-08-17 17:37 ` Thomas S. Dye
  2011-08-19 12:59 ` Eric Schulte
  2 siblings, 0 replies; 4+ messages in thread
From: Sebastien Vauban @ 2011-08-17 13:51 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Andras,

Andras Major wrote:
> I've been trying to use org-mode for report generation lately, and
> haven't really succeeded. Here's a list of issues I encounter:
>
> - Babel offers a way of generating a code block from the output or
>   value of a code block.  That new block, however, is forced to the
>   same language as the original block -- that is doesn't allow me, for
>   example, to use a Haskell block to create an asymptote figure which
>   then generates an image in the HTML or PDF export version.  Is there
>   a way around this limitation?

I had the similar wish some months ago. See thread
http://www.mail-archive.com/emacs-orgmode-mXXj517/zsQ@public.gmane.org/msg35290.html for another
use case.

No idea about the rest of your email...

> - Ruby: is inf-ruby really required? Why can't I execute a ruby block
>   without it?
>
> - Haskell: there are at least two interpreters that babel will invoke,
>   depending on what is available (ghci and hugs), and those two are
>   incompatible in some areas (such as loading modules, where the
>   commands are different -- :add vs. :load). I haven't found a way of
>   + forcing the use of a specific interpreter;
>   + specifying command-line arguments to the interpreter (which would
>     eliminate the need for :add or :load).
>   This really makes using Haskell rather hit-and-miss, see below.
>
> - Haskell code usage is rather cumbersome: since Babel invokes an
>   interpreter rather than runghc, a Haskell block doesn't nearly have
>   the flexibility of a real Haskell program.  In particular, one can
>   only make definitions (portably) in the Haskell code by creating a
>   separate block which is tangled but not executed.  Another block,
>   which is executed, can then load the tangled module and use its
>   definitions (if it weren't for the problems described above and
>   below).
>
> - The handling of interpreted Haskell appears to be rather dodgy: If I
>   want to load a module (in ghci) and then evaluate some function,
>   then I run into real trouble.  None of my tests run at all when
>   first loaded into emacs, but if I execute some tests in a certain
>   order, it all starts working.  I haven't been able to figure out yet
>   what goes wrong and what "playing around" makes things work, but it
>   appears that
> #+begin_src haskell
>   :add SomeModule
>   someFunction
> #+end_src
>   will not work because the :add statement is ignored. If I put the
>   two lines in separate Haskell blocks and execute each one
>   separately, then things start to work.
>
> - I also tried using sbe to invoke a Haskell function from within a
>   table formula.  Here I usually get an error "ERROR - Undefined
>   variable "x"", which sometimes goes away rather magically (I'm not
>   sure what makes it go away), after which things work just fine.
>   Emacs-lisp blocks written in the same manner work out of the box.
>
> - Haskell uses a static type system, and there is no such thing as
>   automatic casting if a variable has the wrong type for a given
>   function.  Thus, if I evaluate the numbers of a table using Haskell
>   and sbe, and some values have a decimal dot and other (integer) ones
>   omit it, then one of these versions will throw an error.  Is there a
>   way of converting the values beforehand to a given type (say,
>   Double), only to make Haskell happy?
>
> Can anyone give me a hint of why these things don't work and whether
> I'm doing something wrong?
>
> Oh, I'm using emacs from Debian testing (23.2+1-7) and org from git
> (cloned today).

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Babel woes
  2011-08-17 12:59 Babel woes Andras Major
  2011-08-17 13:51 ` Sebastien Vauban
@ 2011-08-17 17:37 ` Thomas S. Dye
  2011-08-19 12:59 ` Eric Schulte
  2 siblings, 0 replies; 4+ messages in thread
From: Thomas S. Dye @ 2011-08-17 17:37 UTC (permalink / raw)
  To: Andras Major; +Cc: emacs-orgmode

Aloha Andras,

Andras Major <andras.g.major@gmail.com> writes:

> Hi everyone,
>
> I've been trying to use org-mode for report generation lately, and
> haven't really succeeded. Here's a list of issues I encounter:
>
> - Babel offers a way of generating a code block from the output or
>   value of a code block.  That new block, however, is forced to the
>   same language as the original block -- that is doesn't allow me, for
>   example, to use a Haskell block to create an asymptote figure which
>   then generates an image in the HTML or PDF export version.  Is there
>   a way around this limitation?

Perhaps you could chain code blocks?  Set your Haskell code block to
:results output and then pass it into the graphing function like this
example dot code block:

#+source: pst-to-fig
#+headers: :file pascals-triangle.pdf :cmdline -Tpdf
#+begin_src dot :var pst-vals=pst-to-dot :exports results
  graph {
    $pst-vals
  }
#+end_src

This is an example Eric Schulte developed.  The Haskell code block in
this instance would be pst-to-dot.

hth,
Tom

>
> - Ruby: is inf-ruby really required? Why can't I execute a ruby block
>   without it?
>
> - Haskell: there are at least two interpreters that babel will invoke,
>   depending on what is available (ghci and hugs), and those two are
>   incompatible in some areas (such as loading modules, where the
>   commands are different -- :add vs. :load). I haven't found a way of
>   + forcing the use of a specific interpreter;
>   + specifying command-line arguments to the interpreter (which would
>     eliminate the need for :add or :load).
>   This really makes using Haskell rather hit-and-miss, see below.
>
> - Haskell code usage is rather cumbersome: since Babel invokes an
>   interpreter rather than runghc, a Haskell block doesn't nearly have
>   the flexibility of a real Haskell program.  In particular, one can
>   only make definitions (portably) in the Haskell code by creating a
>   separate block which is tangled but not executed.  Another block,
>   which is executed, can then load the tangled module and use its
>   definitions (if it weren't for the problems described above and
>   below).
>
> - The handling of interpreted Haskell appears to be rather dodgy: If I
>   want to load a module (in ghci) and then evaluate some function,
>   then I run into real trouble.  None of my tests run at all when
>   first loaded into emacs, but if I execute some tests in a certain
>   order, it all starts working.  I haven't been able to figure out yet
>   what goes wrong and what "playing around" makes things work, but it
>   appears that
> #+begin_src haskell
>   :add SomeModule
>   someFunction
> #+end_src
>   will not work because the :add statement is ignored. If I put the
>   two lines in separate Haskell blocks and execute each one
>   separately, then things start to work.
>
> - I also tried using sbe to invoke a Haskell function from within a
>   table formula.  Here I usually get an error "ERROR - Undefined
>   variable "x"", which sometimes goes away rather magically (I'm not
>   sure what makes it go away), after which things work just fine.
>   Emacs-lisp blocks written in the same manner work out of the box.
>
> - Haskell uses a static type system, and there is no such thing as
>   automatic casting if a variable has the wrong type for a given
>   function.  Thus, if I evaluate the numbers of a table using Haskell
>   and sbe, and some values have a decimal dot and other (integer) ones
>   omit it, then one of these versions will throw an error.  Is there a
>   way of converting the values beforehand to a given type (say,
>   Double), only to make Haskell happy?
>
> Can anyone give me a hint of why these things don't work and whether
> I'm doing something wrong?
>
> Oh, I'm using emacs from Debian testing (23.2+1-7) and org from git
> (cloned today).
>
> Thanks,
>
>   András
>
>

-- 
Thomas S. Dye
http://www.tsdye.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Babel woes
  2011-08-17 12:59 Babel woes Andras Major
  2011-08-17 13:51 ` Sebastien Vauban
  2011-08-17 17:37 ` Thomas S. Dye
@ 2011-08-19 12:59 ` Eric Schulte
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Schulte @ 2011-08-19 12:59 UTC (permalink / raw)
  To: Andras Major; +Cc: emacs-orgmode

Andras Major <andras.g.major@gmail.com> writes:

> Hi everyone,
>
> I've been trying to use org-mode for report generation lately, and
> haven't really succeeded. Here's a list of issues I encounter:
>
> - Babel offers a way of generating a code block from the output or
>   value of a code block.  That new block, however, is forced to the
>   same language as the original block -- that is doesn't allow me, for
>   example, to use a Haskell block to create an asymptote figure which
>   then generates an image in the HTML or PDF export version.  Is there
>   a way around this limitation?
>
> - Ruby: is inf-ruby really required? Why can't I execute a ruby block
>   without it?
>

I just pushed up a fix for this.  inf-ruby is now only required when
session evaluation is used.

I'll preface all of the Haskell questions with the caveat that this may
be the first and most serious use of ob-haskell, so some growing pains
are to be expected.

>
> - Haskell: there are at least two interpreters that babel will invoke,
>   depending on what is available (ghci and hugs), and those two are
>   incompatible in some areas (such as loading modules, where the
>   commands are different -- :add vs. :load). I haven't found a way of
>   + forcing the use of a specific interpreter;
>   + specifying command-line arguments to the interpreter (which would
>     eliminate the need for :add or :load).
>   This really makes using Haskell rather hit-and-miss, see below.
>

ob-haskell uses inf-haskell to evaluate haskell code.  Should a header
argument be added to pass additional arguments to the `run-haskell'
function provided by inf-haskell?  How does non-babel inf-haskell usage
deal with this problem.

>
> - Haskell code usage is rather cumbersome: since Babel invokes an
>   interpreter rather than runghc, a Haskell block doesn't nearly have
>   the flexibility of a real Haskell program.  In particular, one can
>   only make definitions (portably) in the Haskell code by creating a
>   separate block which is tangled but not executed.  Another block,
>   which is executed, can then load the tangled module and use its
>   definitions (if it weren't for the problems described above and
>   below).
>

I am not familiar with runghc, does that allow execution of Haskell
source code in a non-interactive way without explicit compilation.  The
decision to use interactive evaluation for Haskell was motivated by the
desire to avoid an explicit compilation step -- something which has
since been implemented for languages like C and would itself pose
another non-session evaluation option.

>
> - The handling of interpreted Haskell appears to be rather dodgy: If I
>   want to load a module (in ghci) and then evaluate some function,
>   then I run into real trouble.  None of my tests run at all when
>   first loaded into emacs, but if I execute some tests in a certain
>   order, it all starts working.  I haven't been able to figure out yet
>   what goes wrong and what "playing around" makes things work, but it
>   appears that
> #+begin_src haskell
>   :add SomeModule
>   someFunction
> #+end_src
>   will not work because the :add statement is ignored. If I put the
>   two lines in separate Haskell blocks and execute each one
>   separately, then things start to work.
>

That is odd, I would recommend looking in the inf-haskell buffer to see
if any lines are not being passed through to haskell.  If modules must
be loaded before the remainder of the code block is evaluated perhaps a
:modules header argument could be tried.

>
> - I also tried using sbe to invoke a Haskell function from within a
>   table formula.  Here I usually get an error "ERROR - Undefined
>   variable "x"", which sometimes goes away rather magically (I'm not
>   sure what makes it go away), after which things work just fine.
>   Emacs-lisp blocks written in the same manner work out of the box.
>

I'll need a reproducible example to answer this question.

>
> - Haskell uses a static type system, and there is no such thing as
>   automatic casting if a variable has the wrong type for a given
>   function.  Thus, if I evaluate the numbers of a table using Haskell
>   and sbe, and some values have a decimal dot and other (integer) ones
>   omit it, then one of these versions will throw an error.  Is there a
>   way of converting the values beforehand to a given type (say,
>   Double), only to make Haskell happy?
>

yes, you could pass the variables through an elisp function before
passing them to haskell.

>
> Can anyone give me a hint of why these things don't work and whether
> I'm doing something wrong?
>
> Oh, I'm using emacs from Debian testing (23.2+1-7) and org from git
> (cloned today).
>

These problems are most likely largely due to the immaturity of
ob-haskell and not to the specifics of your personal setup.

Best -- Eric

>
> Thanks,
>
>   András
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-08-19 14:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-17 12:59 Babel woes Andras Major
2011-08-17 13:51 ` Sebastien Vauban
2011-08-17 17:37 ` Thomas S. Dye
2011-08-19 12:59 ` Eric Schulte

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).