Re: using template haskell to implement pads forhaskell?

"Claus Reinke" <[email protected]> Mon, 30 Jun 2008 00:18:48 +0100
Newsgroups gmane.comp.lang.haskell.template
Message-ID <016301c8da3e$7d5c5610$e1117ad5@cr3lt>
> (which isn't nice either, as Haskell doesn't have nice multi-line strings).

well, how about using the new quasiquoting to get HereDocs:-)

    {-# LANGUAGE TemplateHaskell #-}
    module Here where

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

    here :: QuasiQuoter
    here = QuasiQuoter (litE . stringL) (litP . stringL)

then

    {-# LANGUAGE QuasiQuotes #-}
    {-# LANGUAGE TemplateHaskell #-}

    import Here

    s = [$here| 
      hello
      multiline
      world
      |]

    test = lines s

gives us

    *Main> test
    [" \r","  hello\r","  multiline\r","  world\r","  "]

Claus