[Template-haskell] using template haskell to implement pads forhaskell?

Claus Reinke claus.reinke at talk21.com
Sun Jun 29 19:18:48 EDT 2008


> (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




More information about the template-haskell mailing list