
Hello, Dear List! I have code (this is the fragment only): {-# LANGUAGE CPP #-} ... ... let user' = ... ... else defect $ logger # ("authentication failure (user: " ++ user' ++ ")") #: __LINE__ ... ... and I get compilation error: • Found hole: __LINE__ :: Int Or perhaps ‘__LINE__’ is mis-spelled, or not in scope • In the second argument of ‘(#:)’, namely ‘__LINE__’ In the second argument of ‘($)’, namely ‘logger # ("authentication failure (user: " ++ user' ++ ")") #: __LINE__’ In the expression: defect $ logger # ("authentication failure (user: " ++ user' ++ ")") #: __LINE__ • Relevant bindings include... ... etc ... But if I change variable name to `userx` (from user'), all is compiled succesflully, no any holes. Where is the hole? --- Best regards, Paul

Hi, cpp easily gets confused by single primes in variables names, which do not exist in C. You can use a better suited cpp implementation, such as http://projects.haskell.org/cpphs/ Greetings, Joachim Am Freitag, den 11.08.2017, 18:25 +0300 schrieb Baa:
Hello, Dear List!
I have code (this is the fragment only):
{-# LANGUAGE CPP #-} ... ... let user' = ... ... else defect $ logger # ("authentication failure (user: " ++ user' ++ ")") #: __LINE__ ... ...
and I get compilation error:
• Found hole: __LINE__ :: Int Or perhaps ‘__LINE__’ is mis-spelled, or not in scope • In the second argument of ‘(#:)’, namely ‘__LINE__’ In the second argument of ‘($)’, namely ‘logger # ("authentication failure (user: " ++ user' ++ ")") #: __LINE__’ In the expression: defect $ logger # ("authentication failure (user: " ++ user' ++ ")") #: __LINE__ • Relevant bindings include... ... etc ...
But if I change variable name to `userx` (from user'), all is compiled succesflully, no any holes. Where is the hole?
--- Best regards, Paul _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post. -- Joachim “nomeata” Breitner mail@joachim-breitner.de https://www.joachim-breitner.de/

On Fri, Aug 11, 2017 at 11:25 AM, Baa
I have code (this is the fragment only):
{-# LANGUAGE CPP #-} ... ... let user' = ... ... else defect $ logger # ("authentication failure (user: " ++ user' ++ ")") #: __LINE__ ... ...
and I get compilation error:
• Found hole: __LINE__ :: Int Or perhaps ‘__LINE__’ is mis-spelled, or not in scope
You do understand that CPP refers to the C preprocessor, correct? Or perhaps it is C syntax that you are unaware of. Haskell does not get to tell a C preprocessor to follow Haskell rules instead of C rules. In the referenced chunk, there are two things that can cause problems: the single quote, which in the C preprocessor begins a string-like entity (character literal.. for historical reasons, C (char) literals can have multiple characters!), and the # which in mid-line indicates a token pasting operation of some kind. And in this particular case, the #s probably just got eaten, and the ' means the following __LINE__ was in what the C preprocessor thought was a long (char) constant and therefore did not get expanded. Since it has a leading underscore in its name, and is not known to be bound *at the Haskell level*, it is interpreted as a hole. If you are using LANGUAGE CPP, you must avoid Haskell syntax that is not also valid C tokens. This is the downside of using a tool intended for a different language with different syntax rules. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
participants (3)
-
Baa
-
Brandon Allbery
-
Joachim Breitner