A 3-line program that does not work

I have a friend who is an architect. I asked her why she does not use Haskell, since she is fond of functional programming. She writes her scripts in Clean, and needs to compile them before using them to generate postscript diagrams. In Haskell, I told her, she could use runghc, and skip the compilation step. She told me that she would consider switching to Haskell, and skipping the compilation step, if I could tell her how to write "façade" in Haskell. C:\ghc\hastex>runghc tudin.hs tudin.hs:10:19: lexical error in string/character literal (UTF-8 decoding error) After browsing the Internet, I noticed that a many of people are having the same problem. Could someone tell me what is wrong with my friend's program? import System.IO main= do outh <- openFile "garb.tsm" WriteMode hPutStrLn outh "A façade is the exterior of a building" hClose outh I would appreciate a "normal" solution, that is, I would like to type the text in any editor, or generate it with LaTeX macros, and compile it using ghc. __________________________________________________________________ Make your browsing faster, safer, and easier with the new Internet Explorer® 8. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/

Am Samstag 24 Oktober 2009 22:27:39 schrieb Philippos Apolinarius:
I have a friend who is an architect. I asked her why she does not use Haskell, since she is fond of functional programming. She writes her scripts in Clean, and needs to compile them before using them to generate postscript diagrams. In Haskell, I told her, she could use runghc, and skip the compilation step. She told me that she would consider switching to Haskell, and skipping the compilation step, if I could tell her how to write "façade" in Haskell.
C:\ghc\hastex>runghc tudin.hs
tudin.hs:10:19: lexical error in string/character literal (UTF-8 decoding error)
After browsing the Internet, I noticed that a many of people are having the same problem. Could someone tell me what is wrong with my friend's program?
import System.IO
import qualified System.IO.UTF8 as U
main= do outh <- openFile "garb.tsm" WriteMode
U.hPutStrLn outh "A façade is the exterior of a building"
hClose outh I would appreciate a "normal" solution, that is, I would like to type the text in any editor, or generate it with LaTeX macros, and compile it using ghc.
works here

phi500ac:
I have a friend who is an architect. I asked her why she does not use Haskell, since she is fond of functional programming. She writes her scripts in Clean, and needs to compile them before using them to generate postscript diagrams. In Haskell, I told her, she could use runghc, and skip the compilation step. She told me that she would consider switching to Haskell, and skipping the compilation step, if I could tell her how to write "fa ade" in Haskell.
C:\ghc\hastex>runghc tudin.hs
tudin.hs:10:19: lexical error in string/character literal (UTF-8 decoding error)
After browsing the Internet, I noticed that a many of people are having the same problem. Could someone tell me what is wrong with my friend's program?
import System.IO
main= do outh <- openFile "garb.tsm" WriteMode hPutStrLn outh "A fa ade is the exterior of a building" hClose outh
I would appreciate a "normal" solution, that is, I would like to type the text in any editor, or generate it with LaTeX macros, and compile it using ghc.
Use the utf8-string package to output utf8 to files. Something like: import qualified System.IO.UTF8 as U import System.IO main = do let s = "A façade is the exterior of a building" writeFile "garb.tsm" s t <- readFile "garb.tsm" print (s == t) Which we can check keeps the characters: $ runhaskell A.hs True Note that GHC 6.12 supports arbitrary encodings on Handles, making this even easier, http://ghcmutterings.wordpress.com/2009/09/30/heads-up-what-you-need-to-know...

On Sat, Oct 24, 2009 at 01:27:39PM -0700, Philippos Apolinarius wrote:
I have a friend who is an architect. I asked her why she does not use Haskell, since she is fond of functional programming. She writes her scripts in Clean, and needs to compile them before using them to generate postscript diagrams. In Haskell, I told her, she could use runghc, and skip the compilation step. She told me that she would consider switching to Haskell, and skipping the compilation step, if I could tell her how to write "façade" in Haskell.
C:\ghc\hastex>runghc tudin.hs
tudin.hs:10:19: lexical error in string/character literal (UTF-8 decoding error)
After browsing the Internet, I noticed that a many of people are having the same problem. Could someone tell me what is wrong with my friend's program?
Her editor probably saved the file in a text encoding other than UTF-8, such as ISO-8859-1. By definition a Haskell program is a Unicode text document. runhaskell is encountering an invalid UTF-8 sequence E7 61 while decoding your program file. The other responses will be relevant too, once the program is lexically correct. Regards, Reid Barton
participants (4)
-
Daniel Fischer
-
Don Stewart
-
Philippos Apolinarius
-
Reid Barton