
On Tue, Mar 12, 2013 at 3:32 PM, Jacques Carette
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) -> ParserSpec a -> ParserSpec b
does not work. The flaw is indeed in FMap. It should not take a function as first argument, but rather a *description* of a function (the same way ParserSpec gives you a description of a parser). Then you can make it work, if your 'description' language is adequate.
Right. But, then I would not be able to use Haskell's existing do notation -- and I would have to poorly recreate a subset of Haskell. And, I think, ParsecSpec would not be a real monad. But.. that is sort of the conclusion -- if you want to do compile-time generation, then the data-type can not contain any function values -- at least none that would need to be lifted into the generated code. And, there is no way to make a type with a real Monad instance which does not contain such a function.