Re: [Haskell-cafe] combined parsing pretty-printing

2011-02-05 Thread Ozgur Akgun
Tillmann,

I've been looking into you packages, very neat ideas and a nice
implementation really.

I've already implemented a toy example and it worked great. Now I am trying
to use your library in a more serious piece of code, and I've realised that
defineIsomorphisms doesn't support record constructors. To be precise, you
handle the case for NormalC in the code, however you do not handle RecC. I
don't think this will be a difficult thing to add. Is there any reason for
you not to support RecC?

Best,

2011/1/26 Tillmann Rendel ren...@informatik.uni-marburg.de

 Hi Ozgur,

 Ozgur Akgun wrote:

 I can write (separately) a parser and a pretty-printer [...]

 Is there any work to combine the two?


 Brent Yorgey wrote:

 Maybe take a look at Invertible Syntax Descriptions: Unifying Parsing
 and Pretty Printing by Tillmann Rendel and Klaus Ostermann from last
 year's Haskell Symposium:

   http://www.informatik.uni-marburg.de/~rendel/unparse/

 It's a beautiful paper, and perhaps the code will work for you
 (although it's too bad it's not on Hackage).


 Indeed, I started this project for exactly the reason Ozgur describes: I
 needed to duplicate a lot of information between parsers and pretty printers
 and was annoyed about it. With invertible syntax descriptions, I now write a
 single program, which looks like a combinator parser (think Parsec), but
 can work as a pretty printer, too.

 I just uploaded the code from the paper (and some additional combinators)
 to Hackage:

  http://hackage.haskell.org/package/partial-isomorphisms
  http://hackage.haskell.org/package/invertible-syntax

 I use this code for the implementation of some very small languages (think
 lambda calculus). This works fine.

 I haven't really tried it for larger languages, but we have two students
 here in Marburg implementing a parser for Java using the library, so we are
 going to have experience with larger languages in a few weeks (months?).

 If you give it a try, I would be happy to receive success stories, bug
 reports, patches, feature requests etc. I want to keep working on this, and
 I am open for suggestions.

  Tillmann


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




-- 
Ozgur Akgun
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] combined parsing pretty-printing

2011-02-05 Thread Ozgur Akgun
Great! That was pretty fast :)

Are you going to update invertible-syntax to use partial-isomorphisms-0.2?

2011/2/5 Tillmann Rendel tillm...@rendel.net

 Hi Ozgur,

 Ozgur Akgun wrote:

 I've already implemented a toy example and it worked great. Now I am
 trying
 to use your library in a more serious piece of code, and I've realised
 that
 defineIsomorphisms doesn't support record constructors. To be precise, you
 handle the case for NormalC in the code, however you do not handle RecC. I
 don't think this will be a difficult thing to add. Is there any reason for
 you not to support RecC?


 No reason at all. I just generalized the Template Haskell macros. They now
 support:

  * newtypes
  * infix constructors
  * record constructors

 Infix constructors are only support by constructorIso, though, not by
 defineIsomorphisms, because I can't think of a good automatic naming scheme.
 Suggestions welcome.

 The code is on hackage.

 There are still some constructors which are not supported: constructors of
 GADTs as well as data or newtype instances, and constructors with
 existentials. I would need to think about typing issues before supporting
 these.

  Tillmann




-- 
Ozgur Akgun
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] combined parsing pretty-printing

2011-01-26 Thread Ozgur Akgun
Dear Café,

I working on a DSL represented by a algebraic data type with many
constructors. I can write (separately) a parser and a pretty-printer for it,
and I am doing so at the moment. However, this way it feels like repeating
the same information twice.

Is there any work to combine the two?

Best,
Ozgur
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] combined parsing pretty-printing

2011-01-26 Thread Brent Yorgey
On Wed, Jan 26, 2011 at 04:22:00PM +, Ozgur Akgun wrote:
 Dear Café,
 
 I working on a DSL represented by a algebraic data type with many
 constructors. I can write (separately) a parser and a pretty-printer for it,
 and I am doing so at the moment. However, this way it feels like repeating
 the same information twice.
 
 Is there any work to combine the two?

Maybe take a look at Invertible Syntax Descriptions: Unifying Parsing
and Pretty Printing by Tillmann Rendel and Klaus Ostermann from last
year's Haskell Symposium:

  http://www.informatik.uni-marburg.de/~rendel/unparse/

It's a beautiful paper, and perhaps the code will work for you
(although it's too bad it's not on Hackage).

-Brent

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


Re: [Haskell-cafe] combined parsing pretty-printing

2011-01-26 Thread malcolm.wallace
Tillmann Rendel and Klaus Ostermann. "Invertible syntax descriptions: Unifying parsing and pretty printing".Haskell Symposium 2010.Regards,MalcolmOn 26 Jan, 2011,at 04:22 PM, Ozgur Akgun ozgurak...@gmail.com wrote:Dear Café,I working on a DSL represented by a algebraic data type with many constructors. I can write (separately) a parser and a pretty-printer for it, and I am doing so at the moment. However, this way it feels like repeating the same information twice.
Is there any work to combine the two?Best,
Ozgur
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] combined parsing pretty-printing

2011-01-26 Thread Jonas Almström Duregård
Depending on your concrete syntax, you may be able to use BNFC
(http://hackage.haskell.org/package/BNFC).

/J

On 26 January 2011 17:22, Ozgur Akgun ozgurak...@gmail.com wrote:
 Dear Café,
 I working on a DSL represented by a algebraic data type with many
 constructors. I can write (separately) a parser and a pretty-printer for it,
 and I am doing so at the moment. However, this way it feels like repeating
 the same information twice.

 Is there any work to combine the two?
 Best,
 Ozgur
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



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


Re: [Haskell-cafe] combined parsing pretty-printing

2011-01-26 Thread Steffen Schuldenzucker

On 01/26/2011 05:22 PM, Ozgur Akgun wrote:
I working on a DSL represented by a algebraic data type with many 
constructors. I can write (separately) a parser and a pretty-printer 
for it, and I am doing so at the moment. However, this way it feels 
like repeating the same information twice.


Is there any work to combine the two?


You might want to take a look at [1, 2]XML Picklers from [3]HXT.

Steffen

[1] 
http://www.haskell.org/haskellwiki/HXT/Conversion_of_Haskell_data_from/to_XML

[2] http://blog.typlab.com/2009/11/writing-a-generic-xml-pickler/
[3] http://hackage.haskell.org/package/hxt-9.0.1



Best,
Ozgur


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


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


Re: [Haskell-cafe] combined parsing pretty-printing

2011-01-26 Thread Tillmann Rendel

Hi Ozgur,

Ozgur Akgun wrote:

I can write (separately) a parser and a pretty-printer [...]
Is there any work to combine the two?


Brent Yorgey wrote:

Maybe take a look at Invertible Syntax Descriptions: Unifying Parsing
and Pretty Printing by Tillmann Rendel and Klaus Ostermann from last
year's Haskell Symposium:

   http://www.informatik.uni-marburg.de/~rendel/unparse/

It's a beautiful paper, and perhaps the code will work for you
(although it's too bad it's not on Hackage).


Indeed, I started this project for exactly the reason Ozgur describes: I 
needed to duplicate a lot of information between parsers and pretty 
printers and was annoyed about it. With invertible syntax descriptions, 
I now write a single program, which looks like a combinator parser 
(think Parsec), but can work as a pretty printer, too.


I just uploaded the code from the paper (and some additional 
combinators) to Hackage:


  http://hackage.haskell.org/package/partial-isomorphisms
  http://hackage.haskell.org/package/invertible-syntax

I use this code for the implementation of some very small languages 
(think lambda calculus). This works fine.


I haven't really tried it for larger languages, but we have two students 
here in Marburg implementing a parser for Java using the library, so we 
are going to have experience with larger languages in a few weeks 
(months?).


If you give it a try, I would be happy to receive success stories, bug 
reports, patches, feature requests etc. I want to keep working on this, 
and I am open for suggestions.


  Tillmann

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