ghc reports errors in wrong lines for functions employing hsp

24 views
Skip to first unread message

Facundo Domínguez

unread,
Dec 5, 2011, 2:39:12 PM12/5/11
to haskell-se...@googlegroups.com
Hi List,
I'd like to file this bug. Please, let me know if there is a better
place for that.

ghc reports an error in line 12 of the following program. The error is
pasted below.

The expected behavior is to have ghc report the error in line 8, as it
would normally happen if the error occurred in a file which is not
preprocessed.

> {-# OPTIONS_GHC -F -pgmFtrhsx #-}
>
> import HSP
>
> main = (putStrLn =<<)$ fmap (renderAsHTML . snd)$ evalHSP Nothing$
> <html>
> <body>
> <% "hello" == 2 %>
> </body>
> </html>


test.hs:12:32:
Couldn't match type `XML' with `Bool'
In the first argument of `asChild', namely
`((asChild ("hello" == 2)))'
In the expression: asChild ((asChild ("hello" == 2)))
In the third argument of `genElement', namely
`[asChild ((asChild ("hello" == 2)))]'


Regards!
Facundo

Jeremy Shaw

unread,
Dec 6, 2011, 1:46:52 PM12/6/11
to haskell-se...@googlegroups.com
If we run trhsx on this document we see:

$ trhsx test.hs 
{-# LINE 1 "test.hs" #-}
{-# OPTIONS_GHC -F -pgmFtrhsx  #-}
module Main (main) where
{-# LINE 2 "test.hs" #-}
import HSP
{-# LINE 3 "test.hs" #-}
main
  = (putStrLn =<<) $
      fmap (renderAsHTML . snd) $
        evalHSP Nothing $
          (genElement (Nothing, "html") []
             [asChild
                ((genElement (Nothing, "body") []
                    [asChild ((asChild ("hello" == 2)))]))])

So, it looks like the LINE pragmas that trhsx inserts are correct. But that it does not insert enough of them ?

- jeremy

2011/12/5 Facundo Domínguez <facundo...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Haskell Server Pages" group.
To post to this group, send email to haskell-se...@googlegroups.com.
To unsubscribe from this group, send email to haskell-server-p...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/haskell-server-pages?hl=en.


Niklas Broberg

unread,
Dec 6, 2011, 3:04:20 PM12/6/11
to haskell-se...@googlegroups.com


On Tue, Dec 6, 2011 at 7:46 PM, Jeremy Shaw <jash...@gmail.com> wrote:
If we run trhsx on this document we see:

$ trhsx test.hs 
{-# LINE 1 "test.hs" #-}
{-# OPTIONS_GHC -F -pgmFtrhsx  #-}
module Main (main) where
{-# LINE 2 "test.hs" #-}
import HSP
{-# LINE 3 "test.hs" #-}
main
  = (putStrLn =<<) $
      fmap (renderAsHTML . snd) $
        evalHSP Nothing $
          (genElement (Nothing, "html") []
             [asChild
                ((genElement (Nothing, "body") []
                    [asChild ((asChild ("hello" == 2)))]))])

So, it looks like the LINE pragmas that trhsx inserts are correct. But that it does not insert enough of them ?

Thanks for the report Facundo, and thanks for digging in to the matter Jeremy. It's clear that haskell-src-exts doesn't insert enough LINE pragmas, though I'm not sure if it can ever be perfect. I'll look into it though, surely I can do better than the current situation.

But in the longer run, the plan is to switch trhsx over to the exact-printer rather than the pretty-printer. That move should give far more precision.

And in the even longer run, the plan is to complete the type checker that would allows us to type check directly on the hsx code, rather than waiting for GHC to do it on the post-processed code.

Anyone feel like hiring me for a month or two, so I can take the time off from my current job and do some hsp-related work for a while? ;-)

Cheers,

/Niklas
Reply all
Reply to author
Forward
0 new messages