1

I'm using the simple quasiquoter from the Haskell Wiki for multiline strings.

import Language.Haskell.TH
import Language.Haskell.TH.Quote

str = QuasiQuoter { quoteExp = stringE }

I get the following warning:

    Fields of ‘QuasiQuoter’ not initialised: quotePat, quoteType,
                                             quoteDec
    In the expression: QuasiQuoter {quoteExp = stringE}
    In an equation for ‘str’: str = QuasiQuoter {quoteExp = stringE}

What is the proper way to squelch this warning? Should I be initialising quotePat etc, perhaps to undefined or something else?

Steven Shaw
  • 6,063
  • 3
  • 33
  • 44

1 Answers1

1

from https://hackage.haskell.org/package/template-haskell/docs/Language-Haskell-TH-Quote.html#t:QuasiQuoter

if you are only interested in defining a quasiquoter to be used for expressions, you would define a QuasiQuoter with only quoteExp, and leave the other fields stubbed out with errors.

So using undefined fields QQ seems to be fine. If you want to just supress warring you can try:

qqUndef = QuasiQuoter {quoteExp = undefined , 
                       quotePat = undefined , 
                       quoteType = undefined,
                       quoteDec = undefined }

-- replace only quoteExp
str = qqUndef { quoteExp = stringE }
Luka Rahne
  • 10,336
  • 3
  • 34
  • 56
  • Thanks! Yes, I just wanted to suppress the warning. – Steven Shaw Aug 15 '16 at 10:11
  • 1
    I updated your answer to the code I used, using `error ""` rather than simply `undefined`. I hope that means that if I use `str` incorrectly, it wouldn't be so hard to track down. – Steven Shaw Aug 15 '16 at 10:20