hi Can anyone advise me on how to check whether a string contains ints, chars, bools, etc.... "2345 + 6767" shoudl give IntAdd (2345) (6767) "2345" should give IntT 2345 Ryan _________________________________________________________________ Who's friends with who and co-starred in what? http://www.searchgamesbox.com/celebrityseparation.shtml
you need to write a parser. Parser is a popular library on hackage that should do what you want. (I have never used it though.) Or read http://citeseer.ist.psu.edu/50754.html and adopt the code from there to your purposes. I found this paper extremely helpful when I needed to build a parser. t. Ryan Bloor <ryanbloor@hotmail.com> Sent by: haskell-cafe-bounces@haskell.org 12/06/2007 12:06 PM To <haskell-cafe@haskell.org> cc Subject [Haskell-cafe] parser hi Can anyone advise me on how to check whether a string contains ints, chars, bools, etc.... "2345 + 6767" shoudl give IntAdd (2345) (6767) "2345" should give IntT 2345 Ryan Get closer to the jungle. I'm a Celebrity Get Me Out Of Here! _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe --- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
On 6 dec 2007, at 18:06, Ryan Bloor wrote:
Can anyone advise me on how to check whether a string contains ints, chars, bools, etc....
"2345 + 6767" shoudl give IntAdd (2345) (6767) "2345" should give IntT 2345 You need to write a parser. There are a lot of libraries that will help you write a parser. One library that is often used for writing parsers in Haskell is called Parsec [1]. There's good documentation on that site on how to use it. Parsec is already included in you distribution. Good luck!
-chris [1]: http://legacy.cs.uu.nl/daan/parsec.html
participants (3)
-
Chris Eidhof -
Ryan Bloor -
Thomas Hartman