Quasi quoting
Robert Greayer
robgreayer at gmail.com
Mon Feb 1 15:10:25 EST 2010
>
> A variant of your suggestion would be: for any quote [|..blah..|] behave as if the programmer had written [quasiQuoter| ...blah...|]. That is, simply pick up whatever record named "quasiQuoter" is in scope. Then you'd say
> import Pads( quasiQuoter )
> and away you go. But you can only use one at a time.
>
> That might be quite convenient, but alas [|...|] has already been taken by Template Haskell quotes, meaning [e| ...|]. So you'd need something else. [*|...|] perhaps.
>
Would it be possible to have [| ... |] mean [quasiQuoter| ... |] iff a
'quasiQuoter' has been imported, but otherwise mean [e| ... |]? Or
does the determination to treat [something| .. blah .. |] as a quasi
quote need to be made before it is possible to determine if there
really is a 'something' available to process the quasi quote?
You could also explicitly rely on the presence/absence of the
QuasiQuotes and TemplateHaskell language options (iff QQ is on, [| ...
|] means [quasiQuoter| ... |], forcing the explicit [e| ... |] for TH
expression quotes). Better for one extension to steal syntax from
another, perhaps, than stealing it from the base language.
As Henrik points out (in his parallel reply) this only really matters
if your quasi-quoted strings are quite short. I only recently came up
with a use case in which a really terse quasi-quotation would be
helpful; heretofore lengthy quotations were all that I had used.
Nevertheless, the proposal as it stands would allow me to get away
with a quasi-quotation that's only one character less terse than my
'implicit' suggestion would allow.
Thanks,
Rob
More information about the Glasgow-haskell-users
mailing list