[Haskell-beginners] Parsing Terms in Brackets for Calculator

Leonhard Applis Leonhard.Applis at protonmail.com
Sat Feb 2 08:02:36 UTC 2019


Hello,

I'm currently doing my first steps in Haskell with a calculator and I'm stuck at the parser.
I have a data Term which will build ... basically a tree of operations, and works fine.

I need help for the function
termify :: [Either Operator Term] -> Term

It takes operators (such as +,**) and terms and output a new, bigger term and is mostly trivial.
However, all attempts I've done for parsing brackets seem very ... crude and not like Haskell at all.

The very first pattern match should check for the innermost brackets, and return termify for everything in between.
I guess that I'm missing some really cool, haskelly solution here.

Best Regards
Leonhard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20190202/21208409/attachment.html>


More information about the Beginners mailing list