[Haskell-cafe] Input and output of mathematical expressions

3 views
Skip to first unread message

Jacek Generowicz

unread,
Jun 9, 2011, 10:23:20 AM6/9/11
to haskell-cafe Cafe
Greetings Cafe,

What would you recommend as a Haskell-based means of interactively
reading and writing mathematical formulae?

As a toy example, what might I use to write a program which presents
the user with

Please simplify the expression: \pi x^2 + 3\pi x^2

(Where the TeX-style expression would be presented with a greek pi and
superscript twos on the xs.)

The user should then have the ability to reply with something that
looks like the result of TeXing

5 \pi x^2

Whatever means the user uses to enter this expression, he should be
able to preview the "typeset" version of his input before submitting.

Any ideas?

Thanks.


_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Chris Smith

unread,
Jun 9, 2011, 10:59:00 AM6/9/11
to Jacek Generowicz, haskell-cafe Cafe

Ae you looking to do this in a web application, or client-side?  Since one of your requirements is to display a typeset equation, that makes a bit of difference.  In a web-based setting, the best way to do that is probably MathML, whereas a GUI will be a bit harder.

Daniel Patterson

unread,
Jun 9, 2011, 11:04:46 AM6/9/11
to haskell-cafe Cafe
(I originally sent this reply from the wrong address, see below)

On Jun 9, 2011, at 11:03 AM, Daniel Patterson wrote:
Also if you are doing this for web, I haven't used it personally (yet), but http://www.mathjax.org/ looks really good... would allow you to actually just write it in LaTeX (as writing MathML by hand is not something I'd like to subject anyone to).

John MacFarlane

unread,
Jun 9, 2011, 11:47:12 AM6/9/11
to haskell-cafe Cafe
There's also http://hackage.haskell.org/package/texmath
which converts LaTeX to MathML, and even handles LaTeX
macros. The problem is that MathML support in browsers
is still spotty.

http://hackage.haskell.org/packages/archive/texmath/0.5.0.1/doc/html/Text-TeXMath-Types.html
contains types for representing formulas in Haskell.

John

+++ Daniel Patterson [Jun 09 11 11:04 ]:


> (I originally sent this reply from the wrong address, see below)
>
> On Jun 9, 2011, at 11:03 AM, Daniel Patterson wrote:
>
> Also if you are doing this for web, I haven't used it personally (yet),

> but [1]http://www.mathjax.org/ looks really good... would allow you to


> actually just write it in LaTeX (as writing MathML by hand is not
> something I'd like to subject anyone to).
> On Jun 9, 2011, at 10:59 AM, Chris Smith wrote:
>
> Ae you looking to do this in a web application, or client-side?
> Since one of your requirements is to display a typeset equation,
> that makes a bit of difference. In a web-based setting, the best
> way to do that is probably MathML, whereas a GUI will be a bit
> harder.
>
> On Jun 9, 2011 8:24 AM, "Jacek Generowicz"

> <[2]jacek.ge...@cern.ch> wrote:
> > Greetings Cafe,
> >
> > What would you recommend as a Haskell-based means of interactively
> > reading and writing mathematical formulae?
> >
> > As a toy example, what might I use to write a program which presents
> > the user with
> >
> > Please simplify the expression: \pi x^2 + 3\pi x^2
> >
> > (Where the TeX-style expression would be presented with a greek pi
> and
> > superscript twos on the xs.)
> >
> > The user should then have the ability to reply with something that
> > looks like the result of TeXing
> >
> > 5 \pi x^2
> >
> > Whatever means the user uses to enter this expression, he should be
> > able to preview the "typeset" version of his input before submitting.
> >
> > Any ideas?
> >
> > Thanks.
> >
> >
> > _______________________________________________
> > Haskell-Cafe mailing list

> > [3]Haskel...@haskell.org
> > [4]http://www.haskell.org/mailman/listinfo/haskell-cafe
>
> _______________________________________________
> Haskell-Cafe mailing list
> [5]Haskel...@haskell.org
> [6]http://www.haskell.org/mailman/listinfo/haskell-cafe
>
> References
>
> 1. http://www.mathjax.org/
> 2. mailto:jacek.ge...@cern.ch
> 3. mailto:Haskel...@haskell.org
> 4. http://www.haskell.org/mailman/listinfo/haskell-cafe
> 5. mailto:Haskel...@haskell.org
> 6. http://www.haskell.org/mailman/listinfo/haskell-cafe

Jacek Generowicz

unread,
Jun 9, 2011, 12:36:27 PM6/9/11
to Chris Smith, haskell-cafe Cafe

On 2011 Jun 9, at 16:59, Chris Smith wrote:

> Ae you looking to do this in a web application, or client-side?
> Since one of your requirements is to display a typeset equation,
> that makes a bit of difference. In a web-based setting, the best
> way to do that is probably MathML, whereas a GUI will be a bit harder.
>

Yes, this pretty much summarizes my (ignorant) thoughts on it so far
(GUI: hard; MathML: relatively easy), which is why I suspect that
running it as a local web application might be the simplest way to go.

Henning Thielemann

unread,
Jun 9, 2011, 2:33:25 PM6/9/11
to Jacek Generowicz, haskell-cafe Cafe

On Thu, 9 Jun 2011, Jacek Generowicz wrote:

>
> On 2011 Jun 9, at 16:59, Chris Smith wrote:
>
>> Ae you looking to do this in a web application, or client-side? Since one
>> of your requirements is to display a typeset equation, that makes a bit of
>> difference. In a web-based setting, the best way to do that is probably
>> MathML, whereas a GUI will be a bit harder.
>>
> Yes, this pretty much summarizes my (ignorant) thoughts on it so far (GUI:
> hard; MathML: relatively easy), which is why I suspect that running it as a
> local web application might be the simplest way to go.

Concerning a local GUI: How about running LaTeX for Tex->PDF, generate a
PNG from PDF by ghostscript and show the PNG?

Etienne Laurin

unread,
Jun 9, 2011, 10:45:06 PM6/9/11
to haskel...@haskell.org
Henning Thielemann <lemming <at> henning-thielemann.de> writes:
> On Thu, 9 Jun 2011, Jacek Generowicz wrote:
>> On 2011 Jun 9, at 16:59, Chris Smith wrote:
>>
>>> Ae you looking to do this in a web application, or client-side? Since one
>>> of your requirements is to display a typeset equation, that makes a bit of
>>> difference. In a web-based setting, the best way to do that is probably
>>> MathML, whereas a GUI will be a bit harder.
>>>
>> Yes, this pretty much summarizes my (ignorant) thoughts on it so far (GUI:
>> hard; MathML: relatively easy), which is why I suspect that running it as a
>> local web application might be the simplest way to go.
>
> Concerning a local GUI: How about running LaTeX for Tex->PDF, generate a
> PNG from PDF by ghostscript and show the PNG?

I am working on an alternative solution for a local GUI. I am developing an
equation editor and manipulator in Haskell, using gtk2hs. A prototype is
available on Hackage as casui.

Etienne Laurin

Pedro Vasconcelos

unread,
Jun 13, 2011, 4:05:32 AM6/13/11
to haskel...@haskell.org
On Thu, 9 Jun 2011 16:23:20 +0200
Jacek Generowicz <jacek.ge...@cern.ch> wrote:

> Greetings Cafe,
>
> What would you recommend as a Haskell-based means of interactively
> reading and writing mathematical formulae?
>
> As a toy example, what might I use to write a program which presents
> the user with
>
> Please simplify the expression: \pi x^2 + 3\pi x^2
>
> (Where the TeX-style expression would be presented with a greek pi
> and superscript twos on the xs.)
>
> The user should then have the ability to reply with something that
> looks like the result of TeXing
>
> 5 \pi x^2
>
> Whatever means the user uses to enter this expression, he should be
> able to preview the "typeset" version of his input before submitting.
>
> Any ideas?
>
> Thanks.
>


Regarding the rendering math formulas on web browsers: you might want to
have a look at MathJax (http://www.mathjax.org/). You can use LaTeX or
MathML and will work in most browsers (even if when they don't natively
support MathML).

Pedro

Jerzy Karczmarczuk

unread,
Jun 13, 2011, 5:56:21 AM6/13/11
to haskel...@haskell.org
Pedro Vasconcelos comments:

> Regarding the rendering math formulas on web browsers: you might want to
> have a look at MathJax (http://www.mathjax.org/). You can use LaTeX or
> MathML and will work in most browsers (even if when they don't natively
> support MathML).
Don't forget two other (which I have been using for years)

LaTeXMathML : http://math.etsu.edu/LaTeXMathML/
jsMath : http://www.math.union.edu/~dpvc/jsMath/

The first needs MathML, obviously, but I won't use browser which ignores
it... Thios is one script, fairly readable. The second one is much
bigger. Used by Planet Math, integrated into Drupal, etc.
I confess I tried to write something which displayed math fromHaskell, I
gave even a project of that kind to my student. But the solutions exist
already and are known, so...

See e.g.
http://www.twingly.com/haskell/stories/4013ffd773e942fdb4b9cf2cb7c0089e


Jerzy Karczmarczuk

Reply all
Reply to author
Forward
0 new messages