Re: [Haskell-cafe] GHC 6.8.2 on IA64-Linux platform (Itanium)
Hello Sergei! nice to hear from you! In fact I've been dealing with this issue a little bit and just fixed Adjustor issue myself and then just hour before your email came I discovered your excellent gentoo patches! Kudos to zygoloid for his excellent MBlock.h patch! Also you have saved my own time by noting that your patches are already upstream. I've been already thinking about submitting new issue and attaching them there. So I'll just modify platforms wiki and add some notes how to go over IA/Linux ghc 6.8.2 - 7.0.1 gab by using gentoo's patches. Thanks! Karel On 01/ 3/11 09:20 PM, Sergei Trofimovich wrote: On Sun, 02 Jan 2011 18:09:05 +0100 Karel Gardaskarel.gar...@centrum.cz wrote: I'd like to compile more recent than 6.8.2 GHC on itanium-linux system I do have access to, but I'm kind of unlucky with this. I'm trying unregisterised build (of 6.12.3 and 6.10.4) and it always fails with: inplace/bin/ghc-stage2 -H32m -O-package-name dph-base-0.4.0 -hide-all-packages -i -ilibraries/dph/dph-base/. -ilibraries/dph/dph-base/dist-install/build -ilibraries/dph/dph-base/dist-install/build/autogen -Ilibraries/dph/dph-base/dist-install/build -Ilibraries/dph/dph-base/dist-install/build/autogen -Ilibraries/dph/dph-base/include-optP-include -optPlibraries/dph/dph-base/dist-install/build/autogen/cabal_macros.h -package array-0.3.0.1 -package base-4.2.0.2 -package ghc-prim-0.2.0.0 -package random-1.0.0.2 -Odph -funbox-strict-fields -haddock -fcpr-off -XTypeFamilies -XGADTs -XRankNTypes -XBangPatterns -XMagicHash -XUnboxedTuples -XTypeOperators -O2 -XGenerics -fno-warn-deprecated-flags -Wwarn -odir libraries/dph/dph-base/dist-install/build -hidir libraries/dph/dph-base/dist-install/build -stubdir libraries/dph/dph-base/dist-install/build -hisuf hi -osuf o -hcsuf hc -c libraries/dph/dph-base/./Data/Array/Parallel/Base/Hyperstrict.hs -o libraries/dph/dph-base/dist-install/build/Data/Array/Parallel/Base/Hyperstrict.o ghc-stage2: internal error: evacuate: strange closure type 15 (GHC version 6.12.3 for ia64_unknown_linux) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug make[1]: *** [libraries/dph/dph-base/dist-install/build/Data/Array/Parallel/Base/Hyperstrict.o] Aborted make: *** [all] Error 2 [snip] I've also seen, the last available GHC in Debian for IA64 platform is 6.8.2 -- which I'm using for bootstrap btw so debian will not help me here with some clever patch which would change recent ghc to be buildable... So, I'd like to ask here: is there anybody who was lucky enough to find appropriate set of options or any other magic way how to compile more recent GHC sources to the _stable_ compiler binary on IA64/Linux? If so, please let me know. Hello Karel! You have hit a nasty Garbage Collector bug in ghc. I (re)discovered it some months ago too. There is yet some patches to make stuff work on ia64. I think it will be simpler for you to get gentoo's ia64 binaries (unregisterised) and bootstrap ghc-HEAD yourself. http://code.haskell.org/~slyfox/ghc-ia64/ghc-bin-6.12.3-ia64-haddock.tbz2 http://mirrors.kernel.org/gentoo/distfiles/ghc-bin-6.12.3-ia64-haddock.tbz2 We, gentoo, apply patches for ghc-6.12.3 to make magic happen (all gone upstream and ghc-7.0/ghc-7.0.1) http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ In case you will decide to bootstrap stable ghc-6.12.3 the following patches should suffice. == required patches == * GC patch (the critical one, fixes bug you have posted) http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-6.12.3-ia64-storage-manager-fix.patch?revision=1.1view=markup * you need to pass -G0 to gcc when you build ghc. Gentoo does it in a special manner: we add the following to mk/build.mk: SRC_HC_OPTS += -optc-G0 Your approach might be different. It solves known(?) limitation of small object's section size. == nice to have patches == * remove crufty linker flags in order to able to link ghc on recent binutils http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-6.12.3-ia64-fixed-relax.patch?revision=1.1view=markup * f.i.w calls on ia64 (fixes terminfo and thus interactive darcs, otherwise it will SIGSEGV) http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-6.12.3-ia64-use-libffi-for-foreign-import-wrapper.patch?view=markup * If you plan to build haddock using unregistered ghc you'll need one more patch to export needed API (backported from -HEAD). http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-lang/ghc/files/ghc-6.12.3-ghciless-haddock-3558.patch?revision=1.1view=markup Good luck! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Freeglut
On Tue, 04 Jan 2011 00:21:11 +0100, Eric e...@mathmeth.com wrote: Hi all, I would like to use freeglut instead of GLUT for my Haskell OpenGL program, but when I place the freeglut dll in the program's directory and try to run the program on Windows XP, I get the following error message: user error (unknown GLUT call glutSetOption, check for freeglut) Can anyone help? Eric M. I searched for the error message and found the solution at page: http://netsuperbrain.com/blog/posts/freeglut-windows-hopengl-hglut/ Before this blog was written, I had the same problem; I received the following answer from Peter Verswyvelen: But when building GLFW, make sure that the GHC gcc-libdirectory comes *before* the MinGW/Cygwin directory inyour PATH environment variable, since when linking,the LD.EXE bundled with GHC *must* be used. Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html -- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Odd profiling results
http://www.mega-nerd.com/tmp/ddc-heap-usage-20101231.png We have no particular problem with the 11 peaks (one for each source file) but wonder what the hell is going on in the periods when the memory usage is flat. The peaks I am guessing are largely attributable to parsing the source files. Then, once the source has been converted to an AST, the DDC compiler is presumably doing some analysis before moving on to the next file? I think these are the well-behaved flat bits. These phases do not allocate anything fresh, so they are not creating new data-structures, but perhaps are propagating static information around the AST. Something like a type/effect analysis maybe? Regards, Malcolm ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How about Haskell Golf just like vimgolf.com
On Mon, Jan 3, 2011 at 6:19 PM, Ertugrul Soeylemez e...@ertes.de wrote: Alex Kropivny alex.kropi...@gmail.com wrote: Could something like code abstraction be done instead? Haskell lends itself to solving problems in really generic, high level ways that reveal a LOT about the underlying problem structure. Through some combination of descriptive data types, generic type classes, and generic helper functions... You get an extremely clear problem description. Example: https://github.com/amtal/snippets/blob/master/Key.hs (Haskell) versus http://siyobik.info/index.php?module=pastebinid=543 (C++) Clarity is a lot harder to score for, so you'd probably need to score things via votes. (Unless there's a way to measure how generic/high-level code is?) Such a site would fill a very nice role, that the programming language shootout definitely does not fill. Currently the only way to figure out what good Haskell code looks like is to browse lots of blogs, and dig through hackage until you find beautifully written packages. I really like this idea. New concepts in Haskell come up from time to time. Now if there was a competition for code quality and good ideas, they may become more frequent. This could also go for problems, where you have to use some specific feature or extension, like scoped type variables, type families/functional dependencies, or even just typeclasses... (Remember, there was a deep list concatenation problem thread some days ago.) -- Markus Läll ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Template Haskell a Permanent solution?
Am 27.12.2010 08:44, schrieb Henning Thielemann: On Mon, 27 Dec 2010, Jonathan Geddes wrote: #1 Parse a string at compile-time so that a custom syntax for representing data can be used. At the extreme, this data might even be an EDSL. I think it would be enough, if the compiler could be told to unfold an expression like parse text in a domain specific language at compile time. #2 Provide instances automatically. http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/generic-classes.html I see the text below and have no idea where the package lang or the module Generic comes from. Can someone enlighten me? I didn't find package lang on hackage. Cheers Christian 7.16.1. Using generics To use generics you need to * Use the flags -fglasgow-exts (to enable the extra syntax), -XGenerics (to generate extra per-data-type code), and -package lang (to make the Generics library available. * Import the module Generics from the lang package. This import brings into scope the data types Unit, :*:, and :+:. (You don't need this import if you don't mention these types explicitly; for example, if you are simply giving instance declarations.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] GHC.Paths (libDir)
I am looking at GHC API examples page: http://www.haskell.org/haskellwiki/GHC/As_a_library One of examples use import GHC.Paths ( libDir) and mentions that it needs -package ghc-paths option. I tried the second example with latest Haskell Platform (Windows). I commented out libDir = /usr... as it is not applicable to my case and inserted GHC.Paths import. So I run it like ghci -package ghc -package ghc-paths A.hs and get an error that command line: cannot satisfy -package ghc-paths. When I do not use -package ghc-paths, it fails to load a module GHC.Paths. What should I do to obtain libDir? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] GHC.Paths (libDir)
I figured that out, thank you if you are writing answer. ;) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Template Haskell a Permanent solution?
All, 2010/12/27 Jonathan Geddes geddes.jonat...@gmail.com: I see TH used most for the following tasks: #1 Parse a string at compile-time so that a custom syntax for representing data can be used. At the extreme, this data might even be an EDSL. #2 Provide instances automatically. Just a note that TH is also sometimes used in its generality: as a general compile time meta-programming facility. For example, in my experimental grammar-combinators parsing library [1], I am using it to perform grammar transformations at compile time by simply generating the definition for the transformed grammar using TH. This could be extended in the future to provide a low-cost parser generator that works from within TH, which can reuse the library's infrastructure. Dominique [1] http://projects.haskell.org/grammar-combinators/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Template Haskell a Permanent solution?
Christian Maeder schrieb: Am 27.12.2010 08:44, schrieb Henning Thielemann: On Mon, 27 Dec 2010, Jonathan Geddes wrote: #2 Provide instances automatically. http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/generic-classes.html I see the text below and have no idea where the package lang or the module Generic comes from. Can someone enlighten me? The package 'syb' - 'scrap your boilerplate' looks quite similar. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Template Haskell a Permanent solution?
Am 04.01.2011 15:48, schrieb Henning Thielemann: Christian Maeder schrieb: Am 27.12.2010 08:44, schrieb Henning Thielemann: On Mon, 27 Dec 2010, Jonathan Geddes wrote: #2 Provide instances automatically. http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/generic-classes.html I see the text below and have no idea where the package lang or the module Generic comes from. Can someone enlighten me? The package 'syb' - 'scrap your boilerplate' looks quite similar. Yes, thanks. So the documentation should be updated to say package syb and module Data.Generics. @Ian, can you take care of this (without ticket)? Christian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] tplot and splot - analyst's swiss army knifes for visualizing log files
Hi Brandon, I would happily use a better online presentation sharing tool if I knew of one - I am a novice in this respect. Which do you suggest? 02.01.2011, в 3:43, Brandon S Allbery KF8NH allb...@ece.cmu.edu написал(а): -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 still catching up on inbox... On 12/17/10 04:08 , Eugene Kirpichov wrote: Just in case, I'm also attaching a PDF of the current version to this email, but visiting the link is preferable, since I'll be updating the contents. So lessee, I need to get *yet another* account to be able to get updated versions of your document? I expect I won't be updating, then. (No, I'm not on Facebook, and won't be; they aren't going to fix their security and privacy issues because they're where their profit comes from. If I want to give away my vital information to the universe I'll just post my social security/US ID number somewhere, thanks.) - -- brandon s. allbery [linux,solaris,freebsd,perl] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0f2C8ACgkQIn7hlCsL25WbZACgoRAafE2xKTx7z5JxuypZdwRP JXsAnAkjx67HqBFYdobhk0zl9P34Vb95 =bp7O -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANNOUNCE: haskell-src-meta 0.3
It seems I wasn't subscribed to haskell-cafe so this reply didn't get through (sorry for sending this twice, Felipe). I've now subscribed with delivery turned off for -cafe so if you want me to read a response be sure to address me directly :) On Tue, Jan 4, 2011 at 5:08 AM, Ben Millwood hask...@benmachine.co.uk wrote: On Tue, Jan 4, 2011 at 4:02 AM, Felipe Almeida Lessa felipe.le...@gmail.com wrote: On Tue, Jan 4, 2011 at 1:49 AM, Ben Millwood hask...@benmachine.co.uk wrote: haskell-src-meta is a package originally written by Matt Morrow to provide a translation from the syntax tree provided by haskell-src-exts to template haskell syntax. Essentially this allows TH code to be parsed from a string, and is used in several quasiquoter libraries. Are the purposes of haskell-src-meta and haskell-src-exts-qq the same? What are the main differences? Cheers! =) -- Felipe. If you look at the source for Language.Haskell.Exts.Translate from haskell-src-exts-qq [1], you can see that it was actually taken from an earlier version of haskell-src-meta, presumably during the long period for which HSM was not maintained. I guess you could say that it inlined the key parts of haskell-src-meta into its codebase, but I hope that the maintainer can feel more confident about using the haskell-src-meta package as a dependency now. My understanding of the *purpose* of haskell-src-exts-qq is that it is for easily generating ASTs for use with haskell-src-exts, whereas haskell-src-meta is for generating ASTs for use with template haskell. [1] http://hackage.haskell.org/packages/archive/haskell-src-exts-qq/0.3.0/doc/html/src/Language-Haskell-Exts-Translate.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] tplot and splot - analyst's swiss army knifes for visualizing log files
Thanks for pointing out the issue, Lars - though I personally do not think that 2mb is a sizeable chunk by measures of most modern mail hostings, and though the offending letter can simply be deleted, I agree that for some purposes attaching megabyte-sized files to wide mailing list postings is inconvenient. I will consider archive.to in the future. 03.01.2011, в 13:08, Lars Viklund z...@acc.umu.se написал(а): On Fri, Dec 17, 2010 at 12:08:53PM +0300, Eugene Kirpichov wrote: Hello! Actually the presentation was created in PowerPoint, not in TeX :) You can download the PDF here - http://www.slideshare.net/jkff/two-visualization-tools/download (however one has to be logged in to Slideshare, for example with a facebook acct., for this link to work) Just in case, I'm also attaching a PDF of the current version to this email, but visiting the link is preferable, since I'll be updating the contents. Does the list have any policies on not attaching large files? I'd rather not have a sizeable chunk of my mail store consumed by files I am completely uninterested in. As for storing files online, I'm sure that there's download hosting services that do not require any signing in, like say archiv.to or something. -- Lars Viklund | z...@acc.umu.se ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] tplot and splot - analyst's swiss army knifes for visualizing log files
Eugene Kirpichov schrieb: I would happily use a better online presentation sharing tool if I knew of one - I am a novice in this respect. Which do you suggest? For me a plain PDF file, say on code.haskell.org or projects.haskell.org is the best way. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Odd profiling results
Malcolm Wallace wrote: The peaks I am guessing are largely attributable to parsing the source files. Then, once the source has been converted to an AST, the DDC compiler is presumably doing some analysis before moving on to the next file? I think these are the well-behaved flat bits. These phases do not allocate anything fresh, so they are not creating new data-structures, but perhaps are propagating static information around the AST. Something like a type/effect analysis maybe? Thanks Malcolm, I think you may indeed be correct. It should also be pretty easy to test that hypothesis and that is my next task. Cheers, Erik -- -- Erik de Castro Lopo http://www.mega-nerd.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] tplot and splot - analyst's swiss army knifes for visualizing log files
Thanks Hennig, this sounds very good indeed! I haven't thought of this. 04.01.2011, в 22:51, Henning Thielemann schlepp...@henning-thielemann.de написал(а): Eugene Kirpichov schrieb: I would happily use a better online presentation sharing tool if I knew of one - I am a novice in this respect. Which do you suggest? For me a plain PDF file, say on code.haskell.org or projects.haskell.org is the best way. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] tplot and splot - analyst's swiss army knifes for visualizing log files
On Tue, Jan 04, 2011 at 10:44:10PM +0200, Eugene Kirpichov wrote: Thanks for pointing out the issue, Lars - though I personally do not think that 2mb is a sizeable chunk by measures of most modern mail hostings, and though the offending letter can simply be deleted, I agree that for some purposes attaching megabyte-sized files to wide mailing list postings is inconvenient. I will consider archive.to in the future. In order to provide a sense of scale, the allowed size for my mail spool is in the vincinity of tens of megs, and the home directory I can use procmail to sort into mailboxes with is a few gigs, out of which 1.5 gigabytes is taken up by mailing list archives. Not everyone uses gmail, you know, particularly as their threading support is abysmal. -- Lars Viklund | z...@acc.umu.se ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Trouble installing FileManipCompat
Hi, I'm trying to install FileManipCompat(well, really HStringTemplateHelpers, but the error is from FileManipCompat) and I'm getting this error: [1 of 1] Compiling System.FilePath.FindCompat ( System/FilePath/FindCompat.hs, dist/build/System/FilePath/FindCompat.o ) System/FilePath/FindCompat.hs:175:20: Not in scope: data constructor `State' I've attached the complete output of `cabal --verbose install HStringTemplateHelpers`. filemanipcompat.errors Description: Binary data ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Trouble installing FileManipCompat
On Wednesday 05 January 2011 01:54:36, Tony Miller wrote: Hi, I'm trying to install FileManipCompat(well, really HStringTemplateHelpers, but the error is from FileManipCompat) and I'm getting this error: [1 of 1] Compiling System.FilePath.FindCompat ( System/FilePath/FindCompat.hs, dist/build/System/FilePath/FindCompat.o ) System/FilePath/FindCompat.hs:175:20: Not in scope: data constructor `State' Apparently the code is written for an older version of mtl. As of mtl-2.*, State is no longer a separate type, it's a type synonym for StateT s Identity now. You can try $ cabal install --constraint=mtl 2.0 HStringTemplateHelpers (although having multiple versions of mtl installed may lead to some headaches too). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] UTF-8 BOM
I am reading files with System.IO.readFile. Some of these files start with a UTF-8 Byte Order Marker (0xef 0xbb 0xbf). For some functions that process this String, this causes choking so I drop the BOM as shown below. This feels particularly hacky, but I am not in control of many of these functions (that perhaps could use ByteString with a better solution). I'm wondering if there is a better way of achieving this goal. Thanks for any tips. dropBOM :: String - String dropBOM [] = [] dropBOM s@(x:xs) = let unicodeMarker = '\65279' -- UTF-8 BOM in if x == unicodeMarker then xs else s readBOMFile :: FilePath - IO String readBOMFile p = dropBOM `fmap` readFile p -- Tony Morris http://tmorris.net/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Building lambdabot
I've had a bit of an adventure trying to build and run lambdabothttp://hackage.haskell.org/package/lambdabot-4.2.2.1 on my box. 'cabal install lambdabot' does not work. It states it's not GHC 6.12 (and certainly not 7.0) compatible, but I tried 6.12 anyway and got nowhere. Next, I tried 6.10 but failed on the unix dependency (in the same manner as this threadhttp://web.archiveorange.com/archive/v/nDNOvQMXUGwfkyy0ITet). The thread is unresolved, so I've not tried modifying the cabal build-depends. I'm hoping to find someone who has a working lambdabot setup who can point me in the right direction. What further information about my struggles should I provide? Thanks, Joe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] UTF-8 BOM
On Tue, Jan 4, 2011 at 7:08 PM, Tony Morris tonymor...@gmail.com wrote: I am reading files with System.IO.readFile. Some of these files start with a UTF-8 Byte Order Marker (0xef 0xbb 0xbf). For some functions that process this String, this causes choking so I drop the BOM as shown below. This feels particularly hacky, but I am not in control of many of these functions (that perhaps could use ByteString with a better solution). I'm wondering if there is a better way of achieving this goal. Thanks for any tips. dropBOM :: String - String dropBOM [] = [] dropBOM s@(x:xs) = let unicodeMarker = '\65279' -- UTF-8 BOM in if x == unicodeMarker then xs else s readBOMFile :: FilePath - IO String readBOMFile p = dropBOM `fmap` readFile p Are you thinking that the BOM should be automatically stripped from UTF8 text at some low level, if present? I was thinking about it, and I was deeply conflicted about the idea. Then I read the unicode.org BOM faq[1], and I'm still conflicted. I'm thinking that it would be correct behavior to drop the BOM from the start of a UTF8 stream, even at a pretty low level. The FAQ seems to allow it as a means of identifying the stream as UTF8 (although it isn't a reliable means of identifying a stream as UTF8). But I'm no unicode expert. Antoine [1] http://unicode.org/faq/utf_bom.html -- Tony Morris http://tmorris.net/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] UTF-8 BOM
On 11-01-04 08:08 PM, Tony Morris wrote: I am reading files with System.IO.readFile. Some of these files start with a UTF-8 Byte Order Marker (0xef 0xbb 0xbf). There is System.IO.utf8_bom for that. Of course, then you can't use readFile; but you can use openFile and hGetContents. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe