unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [ELPA] New package: parsec
@ 2016-10-25 20:17 Junpeng Qiu
  2016-10-25 20:23 ` Junpeng Qiu
  0 siblings, 1 reply; 4+ messages in thread
From: Junpeng Qiu @ 2016-10-25 20:17 UTC (permalink / raw)
  To: emacs-devel; +Cc: Stefan Monnier

[-- Attachment #1: Type: text/plain, Size: 1531 bytes --]

Hello Emacs,

I've added a new package "parsec" to GNU ELPA (hoping I've not messed up
anything). This is a parser combinator library for Emacs Lisp, similar to
Haskell's parsec. The work is inspired by John's [emacs-pl]. The main repo
of parsec is on GitHub: https://github.com/cute-jumper/parsec.el.

John's [emacs-pl] is awesome, but I found following problems when I tried
to use it:
- it only contains a very limited set of combinators
- Some of its functions (combinators) have different behaviors than their
Haskell counterparts
- It can't show error messages when parsing fails.

The new library, parsec, contains most of the parser combinators in
"Text.Parsec.Combinator" (I'm adding more gradually), and I tried my best
to keep their behavior the same as their Haskell counterparts so that
programmer with Haskell background could easily use the library. You can
see the table listing all of the functions/macros in the README. It's a
long list so I'll skip it here. Parsec also comes with a simple error
handling mechanism, which may be improved in the future.

To give a short example, the following code extract the "hello" from the
comment:

  (parsec-with-input "/* hello */"
    (parsec-string "/*")
    (parsec-many-till-as-string (parsec-any-ch)
                                (parsec-try
                                 (parsec-string "*/"))))

More examples can be found at
https://github.com/cute-jumper/parsec.el/tree/master/examples.

[emacs-pl]: https://github.com/cute-jumper/parsec.el

Thanks,
-Junpeng

[-- Attachment #2: Type: text/html, Size: 2185 bytes --]

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

* Re: [ELPA] New package: parsec
  2016-10-25 20:17 [ELPA] New package: parsec Junpeng Qiu
@ 2016-10-25 20:23 ` Junpeng Qiu
  2016-10-25 21:46   ` John Wiegley
  0 siblings, 1 reply; 4+ messages in thread
From: Junpeng Qiu @ 2016-10-25 20:23 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1819 bytes --]

Sorry. I seemed to paste the wrong URL for John's emacs-pl. Here you go:

[emacs-pl]: https://github.com/jwiegley/emacs-pl

Thanks,
-Junpeng

On Tue, Oct 25, 2016 at 4:17 PM, Junpeng Qiu <qjpchmail@gmail.com> wrote:

> Hello Emacs,
>
> I've added a new package "parsec" to GNU ELPA (hoping I've not messed up
> anything). This is a parser combinator library for Emacs Lisp, similar to
> Haskell's parsec. The work is inspired by John's [emacs-pl]. The main repo
> of parsec is on GitHub: https://github.com/cute-jumper/parsec.el.
>
> John's [emacs-pl] is awesome, but I found following problems when I tried
> to use it:
> - it only contains a very limited set of combinators
> - Some of its functions (combinators) have different behaviors than their
> Haskell counterparts
> - It can't show error messages when parsing fails.
>
> The new library, parsec, contains most of the parser combinators in
> "Text.Parsec.Combinator" (I'm adding more gradually), and I tried my best
> to keep their behavior the same as their Haskell counterparts so that
> programmer with Haskell background could easily use the library. You can
> see the table listing all of the functions/macros in the README. It's a
> long list so I'll skip it here. Parsec also comes with a simple error
> handling mechanism, which may be improved in the future.
>
> To give a short example, the following code extract the "hello" from the
> comment:
>
>   (parsec-with-input "/* hello */"
>     (parsec-string "/*")
>     (parsec-many-till-as-string (parsec-any-ch)
>                                 (parsec-try
>                                  (parsec-string "*/"))))
>
> More examples can be found at https://github.com/cute-
> jumper/parsec.el/tree/master/examples.
>
> [emacs-pl]: https://github.com/cute-jumper/parsec.el
>
> Thanks,
> -Junpeng
>

[-- Attachment #2: Type: text/html, Size: 2839 bytes --]

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

* Re: [ELPA] New package: parsec
  2016-10-25 20:23 ` Junpeng Qiu
@ 2016-10-25 21:46   ` John Wiegley
  2016-10-26  1:46     ` Junpeng Qiu
  0 siblings, 1 reply; 4+ messages in thread
From: John Wiegley @ 2016-10-25 21:46 UTC (permalink / raw)
  To: Junpeng Qiu; +Cc: emacs-devel

>>>>> "JQ" == Junpeng Qiu <qjpchmail@gmail.com> writes:

JQ> Sorry. I seemed to paste the wrong URL for John's emacs-pl. Here you go:
JQ> [emacs-pl]: https://github.com/jwiegley/emacs-pl

Thanks for the link, Junpeng! In return for your gracious contribution, I
offer a new Haskell library to play with that you might find useful, since it
should make it possible for you to compile Haskell-written Parsec parsers into
their corresponding Emacs Lisp "parsec" equivalents -- or at least part of the
way. :)

    http://hackage.haskell.org/package/parsec-free

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2



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

* Re: [ELPA] New package: parsec
  2016-10-25 21:46   ` John Wiegley
@ 2016-10-26  1:46     ` Junpeng Qiu
  0 siblings, 0 replies; 4+ messages in thread
From: Junpeng Qiu @ 2016-10-26  1:46 UTC (permalink / raw)
  To: emacs-devel, jwiegley

[-- Attachment #1: Type: text/plain, Size: 1328 bytes --]

It is a very interesting idea to combine Free Monad with Parsec. I'll take
a look at it.

>> make it possible for you to compile Haskell-written Parsec parsers into
their corresponding Emacs Lisp "parsec" equivalents

It would be awesome if we can finally do this. For the time being, I'll
mainly working on making parsec more complete, porting more Haskell
functions to Emacs Lisp. It still needs to be more polished to become
really useful.

Thanks for your emacs-pl and the information!

Best,
-Junpeng

On Tue, Oct 25, 2016 at 5:46 PM, John Wiegley <jwiegley@gmail.com> wrote:

> >>>>> "JQ" == Junpeng Qiu <qjpchmail@gmail.com> writes:
>
> JQ> Sorry. I seemed to paste the wrong URL for John's emacs-pl. Here you
> go:
> JQ> [emacs-pl]: https://github.com/jwiegley/emacs-pl
>
> Thanks for the link, Junpeng! In return for your gracious contribution, I
> offer a new Haskell library to play with that you might find useful, since
> it
> should make it possible for you to compile Haskell-written Parsec parsers
> into
> their corresponding Emacs Lisp "parsec" equivalents -- or at least part of
> the
> way. :)
>
>     http://hackage.haskell.org/package/parsec-free
>
> --
> John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
> http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2
>

[-- Attachment #2: Type: text/html, Size: 2251 bytes --]

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

end of thread, other threads:[~2016-10-26  1:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-25 20:17 [ELPA] New package: parsec Junpeng Qiu
2016-10-25 20:23 ` Junpeng Qiu
2016-10-25 21:46   ` John Wiegley
2016-10-26  1:46     ` Junpeng Qiu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).