3

It looks like the quasi quoter syntax has changed to now accept 4 arguments [ link ]. Has anyone used it yet? Thanks. I just want to build something really really simple, and the examples on the web won't work now.

Thanks in advance.

gatoatigrado
  • 16,580
  • 18
  • 81
  • 143
  • 1
    Couldn't you just set the new one to `undefined`? (Not sure if that works, very little experience with quasis) – alternative Jul 26 '11 at 22:09

2 Answers2

3

Each piece of the QuasiQuoter is just a function that takes a string (the content of the quasi-quote) and returns an appropriate value in the Q monad. If your quasiquoter doesn't support being used in some of those contexts, just return an error, e.g.:

someQuoter = QuasiQuoter { quoteType = const $ fail "type context unsupported" 
                         , -- etc ...
                         }

The fail method calls report True, which produces a compiler error. This is pretty much the correct behavior.

C. A. McCann
  • 76,893
  • 19
  • 209
  • 302
2

Basically the changes are that you can now make quasiquoters for types and declarations (in addition to expressions and patterns).

It should be fine to set the type/declaration fields to error "This quasiquoter doesn't support splicing types/declarations" if you don't want to use them.

porges
  • 30,133
  • 4
  • 83
  • 114