Interpolation-0.2.1: Multiline strings, interpolation and templating.Source codeContentsIndex
str :: QuasiQuoter
endline :: String
tab :: String
str :: QuasiQuoterSource

Quasiquote str implements multiline strings with interpolation. Interpolating a value into the string is done by $<String expression>$ and interpolating anything with instance Show is $:<Show expression>$. Due to pretty deep limitations, the parser is not able to properly deduce associtivity of infix operators, so use lots and lots of parenthesis.

Repetitive patterns can be made by # symbol:

  #<var> in <list>: <interpolated string> (|<interpolated string>)#

Where (|<interpolated string>) denotes optional separator for the elements.

Multiline indentation is handled by aligning on smallest un-empty line after the first. Neither pattern matching nor nested #-patterns are supported. Normal '\\n' style escaping of special characters is intentionally not supported. Please use $endline$ or $n$ style instead. (Also, in this beta release $, and : symbols are not escaped in the interpolated expressions.

As an example, let's plot set of vectors with gnuplot:

   plotVecs :: [(String,[Double])] -> String
   plotVecs vs =  
       [$str|  Plot multiple vectors
    singleVec n = [$str||]
  *Gnuplotter> plotVecs [(A,[1..5]),(B,[2..6])]
  # Plot multiple vectors
   plot - with lines lw 5 title A , - with lines lw 5 title B 
    1 1.0
    2 2.0
    3 3.0
    4 4.0
    5 5.0

    1 2.0
    2 3.0
    3 4.0
    4 5.0
    5 6.0

endline :: StringSource
End of the line
tab :: StringSource
Produced by Haddock version 2.4.2