
Hi all (and in particular Filipe), I'm looking at Esqueleto and I'm finding that in certain circumstances it can throw out some rather horrid error messages. Consider the correct code fragment taken from the Esqueleto docs: select $ from $ \(b, p) -> do where_ (b ^. BlogPostAuthorId ==. p ^. PersonId) return (b, p) The error occurs if the programmer uses the wrong identifer in the where_ clause. For instance, if PersonId is used instead of BlogPostAuthorId then I get about 100 lines of error message, the majority of which is totally incomprehensible. Is there anything that can be done inside Esqueleto to make these error messages better? Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/

On Wed, Oct 24, 2012 at 10:32 PM, Erik de Castro Lopo
Hi all (and in particular Filipe),
Hey! =)
I'm looking at Esqueleto and I'm finding that in certain circumstances it can throw out some rather horrid error messages. Consider the correct code fragment taken from the Esqueleto docs:
select $ from $ \(b, p) -> do where_ (b ^. BlogPostAuthorId ==. p ^. PersonId) return (b, p)
The error occurs if the programmer uses the wrong identifer in the where_ clause. For instance, if PersonId is used instead of BlogPostAuthorId then I get about 100 lines of error message, the majority of which is totally incomprehensible.
What are those messages?
Is there anything that can be done inside Esqueleto to make these error messages better?
Nothing straightforward, AFAIK. Sadly, the horridness of the error messages is directly proportional to the amount of type hackery in the code. Cheers, =) -- Felipe.

That kind of problem is very common in EDSLs. The problem is that a
EDSL tries to hide complexity, but the error messages expose this
complexity to the userw. So in real terms, it is not possible to make
use of a EDSL in full without knowing in detail the internals. Tha´ts
too bad, specially in industry, where the specialization between
middleware/system/architecture programming and application programming
is common.
Any advance on this would be very necessary. it could be some kind of
magic type trickery or some naming conventions. It sould be very
appreciated.
Another option to exprore would be to permit custom error messages,
where the long messages using the context of the haskell type system
can be postprocessed to generate a simpler message with a clear
meaning in the context of the EDSL.
For me, this is a limitation for haskell to enter in the industry seriously.
2012/10/25 Felipe Almeida Lessa
On Wed, Oct 24, 2012 at 10:32 PM, Erik de Castro Lopo
wrote: Hi all (and in particular Filipe),
Hey! =)
I'm looking at Esqueleto and I'm finding that in certain circumstances it can throw out some rather horrid error messages. Consider the correct code fragment taken from the Esqueleto docs:
select $ from $ \(b, p) -> do where_ (b ^. BlogPostAuthorId ==. p ^. PersonId) return (b, p)
The error occurs if the programmer uses the wrong identifer in the where_ clause. For instance, if PersonId is used instead of BlogPostAuthorId then I get about 100 lines of error message, the majority of which is totally incomprehensible.
What are those messages?
Is there anything that can be done inside Esqueleto to make these error messages better?
Nothing straightforward, AFAIK. Sadly, the horridness of the error messages is directly proportional to the amount of type hackery in the code.
Cheers, =)
-- Felipe.
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel
-- Alberto.

Felipe Almeida Lessa wrote:
What are those messages?
Messages resulting from a single incorrect identifier below. I actually now notice that error for line 76 point to the specific cause, while the multiple errors flagged for line 62 just confuse matters. Part of the confusion is that I tend to look at error messages from top to bottom, possibly from my long term work in C and C++. I'm not sure if the top to bottom approach to reading error messages is valid for Haskell. Cheers, Erik blog.hs:62:15: Couldn't match type `SqlPersist' with `SqlPersist IO (PersonGeneric SqlPersist)' When using functional dependencies to combine Database.Esqueleto.Internal.Sql.SqlSelect (SqlExpr (Entity a)) (Entity a), arising from the dependency `a -> r' in the instance declaration in `Database.Esqueleto.Internal.Sql' Database.Esqueleto.Internal.Sql.SqlSelect (SqlExpr (Entity (PersonGeneric SqlPersist))) (Entity (SqlPersist IO (SqlPersist IO (PersonGeneric SqlPersist)))), arising from a use of `select' at blog.hs:62:15-20 In the expression: select In a stmt of a 'do' block: people <- select $ from $ \ p -> do { where_ (p ^. PersonAge >=. val age); return p } blog.hs:62:15: Couldn't match type `PersonGeneric' with `SqlPersist IO' When using functional dependencies to combine Database.Esqueleto.Internal.Sql.SqlSelect (SqlExpr (Entity a)) (Entity a), arising from the dependency `a -> r' in the instance declaration in `Database.Esqueleto.Internal.Sql' Database.Esqueleto.Internal.Sql.SqlSelect (SqlExpr (Entity (PersonGeneric SqlPersist))) (Entity (SqlPersist IO (SqlPersist IO (PersonGeneric SqlPersist)))), arising from a use of `select' at blog.hs:62:15-20 In the expression: select In a stmt of a 'do' block: people <- select $ from $ \ p -> do { where_ (p ^. PersonAge >=. val age); return p } blog.hs:62:15: Couldn't match type `SqlPersist IO (PersonGeneric SqlPersist)' with `SqlPersist' When using functional dependencies to combine Database.Esqueleto.Internal.Sql.SqlSelect (SqlExpr (Entity a)) (Entity a), arising from the dependency `r -> a' in the instance declaration in `Database.Esqueleto.Internal.Sql' Database.Esqueleto.Internal.Sql.SqlSelect (SqlExpr (Entity (PersonGeneric SqlPersist))) (Entity (SqlPersist IO (SqlPersist IO (PersonGeneric SqlPersist)))), arising from a use of `select' at blog.hs:62:15-20 In the expression: select In a stmt of a 'do' block: people <- select $ from $ \ p -> do { where_ (p ^. PersonAge >=. val age); return p } blog.hs:62:15: Couldn't match type `SqlPersist IO' with `PersonGeneric' When using functional dependencies to combine Database.Esqueleto.Internal.Sql.SqlSelect (SqlExpr (Entity a)) (Entity a), arising from the dependency `r -> a' in the instance declaration in `Database.Esqueleto.Internal.Sql' Database.Esqueleto.Internal.Sql.SqlSelect (SqlExpr (Entity (PersonGeneric SqlPersist))) (Entity (SqlPersist IO (SqlPersist IO (PersonGeneric SqlPersist)))), arising from a use of `select' at blog.hs:62:15-20 In the expression: select In a stmt of a 'do' block: people <- select $ from $ \ p -> do { where_ (p ^. PersonAge >=. val age); return p } blog.hs:76:32: Couldn't match expected type `PersonGeneric backend0' with actual type `BlogPostGeneric backend1' Expected type: EntityField (PersonGeneric backend0) a0 Actual type: EntityField (BlogPostGeneric backend1) String In the second argument of `(^.)', namely `BlogPostTitle' In the first argument of `asc', namely `(b ^. BlogPostTitle)' -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/

On Thu, Oct 25, 2012 at 10:49 AM, Erik de Castro Lopo
Messages resulting from a single incorrect identifier below. I actually now notice that error for line 76 point to the specific cause, while the multiple errors flagged for line 62 just confuse matters. Part of the confusion is that I tend to look at error messages from top to bottom, possibly from my long term work in C and C++. I'm not sure if the top to bottom approach to reading error messages is valid for Haskell.
IME, it depends. My workflow is: 1) Look at the top and see if it's straightforward, 2) Look at the bottom and see if it's straightforward, 3) Scan the rest to find any straightforward error, 4) If everything else fails, dig into one of them. Sometimes when I'm working a lot using a single library (e.g., esqueleto) I begin recognizing some patterns and sometimes switch (1) and (2). BTW, you can get even funkier results if you mix Database.Persistent.Query with esqueleto =). So I really don't know if there's anything I could do to esqueleto to alleviate this problem without losing its expressive syntax. Cheers, -- Felipe.
participants (3)
-
Alberto G. Corona
-
Erik de Castro Lopo
-
Felipe Almeida Lessa