Re: [Haskell-cafe] monadic DSL for compile-time parser generator, not possible?

2013-03-13 Thread Josef Svenningsson
Jeremy, The problem you're trying to solve might seem tricky but it is in fact quite solvable. In Feldspar[1] we use monads quite frequently and generate code from them, in a similar fashion to what you're trying to do. We've written a paper about how we do it[2] that I welcome you to read. If you

Re: [Haskell-cafe] monadic DSL for compile-time parser generator, not possible?

2013-03-13 Thread Dominique Devriese
2013/3/13 Dominique Devriese : > class ProductionRule p => LiftableProductionRule p where > epsilonL :: a -> Q Exp -> p aSource > > and associated > epsilonLS :: (Lift v, LiftableProductionRule p) => v -> p v > epsilonLS v = epsilonL v $ lift v Note that the point of providing epsilonL as pr

Re: [Haskell-cafe] monadic DSL for compile-time parser generator, not possible?

2013-03-13 Thread Dominique Devriese
All, 2013/3/13 : > So, Code is almost applicative. Almost -- because we only have a > restricted pure: > pureR :: Lift a => a -> Code a > with a Lift constraint. Alas, this is not sufficient for realistic > parsers, because often we have to lift functions, as in the example of > parsing a

Re: [Haskell-cafe] monadic DSL for compile-time parser generator, not possible?

2013-03-13 Thread oleg
Jeremy Shaw wrote: > It would be pretty damn cool if you could create a data type for > generically describing a monadic parser, and then use template haskell > to generate a concrete parser from that data type. That would allow > you to create your specification in a generic way and then target >

Re: [Haskell-cafe] monadic DSL for compile-time parser generator, not possible?

2013-03-12 Thread Jeremy Shaw
Mostly, because I want to do other sorts of compile-time inspections on the parser. Being able to generate the parser is just the easiest part to get started with. - jeremy On Tue, Mar 12, 2013 at 3:36 PM, dag.odenh...@gmail.com wrote: > Why not the parsers package [1]? Write the parser against

Re: [Haskell-cafe] monadic DSL for compile-time parser generator, not possible?

2013-03-12 Thread Jeremy Shaw
On Tue, Mar 12, 2013 at 3:32 PM, Jacques Carette wrote: > On 13-03-12 04:06 PM, Jeremy Shaw wrote: >>> data ParserSpec a where >>> AnyChar :: ParserSpec Char >>> Return :: a -> ParserSpec a >>> Join:: ParserSpec (ParserSpec a) -> ParserSpec a >>> FMap:: (a -> b) -> Pa

Re: [Haskell-cafe] monadic DSL for compile-time parser generator, not possible?

2013-03-12 Thread dag.odenh...@gmail.com
Why not the parsers package [1]? Write the parser against the Parsing class and then use trifecta or write instances for attoparsec or parsec. With enough inlining perhaps the overhead of the class gets optimized away? [1] http://hackage.haskell.org/package/parsers On Tue, Mar 12, 2013 at 9:06 P

Re: [Haskell-cafe] monadic DSL for compile-time parser generator, not possible?

2013-03-12 Thread Jacques Carette
On 13-03-12 04:06 PM, Jeremy Shaw wrote: It would be pretty damn cool if you could create a data type for generically describing a monadic parser, and then use template haskell to generate a concrete parser from that data type. [...] I would like to suggest that while it would be cool, it is impo

[Haskell-cafe] monadic DSL for compile-time parser generator, not possible?

2013-03-12 Thread Jeremy Shaw
It would be pretty damn cool if you could create a data type for generically describing a monadic parser, and then use template haskell to generate a concrete parser from that data type. That would allow you to create your specification in a generic way and then target different parsers like parsec