[GHC] #907: Case sensitive ghci commands
#907: Case sensitive ghci commands +--- Reporter: [EMAIL PROTECTED] |Owner: Type: feature request | Status: new Priority: lowest |Milestone: Component: GHCi | Version: 6.4.1 Severity: trivial | Keywords: case command colon Os: Unknown | Difficulty: Easy (1 hr) Architecture: Unknown | +--- In spanish keyboards you have to use the shift key to get a colon (:). This bites me when I do :r in ghci. Half the time I get :R. I would like to request that case made no difference in this case. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/907 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: Year 2038 problem in GHC 6.4.2 runtime
Hello Cyril, Friday, September 22, 2006, 6:16:44 PM, you wrote: As far as I can see, the current (6.4.2) GHC runtime suffers the year 2038 problem; that is, the System.Time module does not support dates from 2038 onwards (the code below reproduces the problem). there is new Time library, which is supposed to replace old System.Time. we hope that it will happen before 2038 :D -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
bug in mallocForeignPtrBytes (both 6.4 and 6.6)
Hello glasgow-haskell-users, the attached program show up the bug in mallocForeignPtrBytes (and newPinnedByteArray#) implementation - it allocates two times more memory as requested. The bug seen both on 6.6rc and june 6.4 windows builds, namely: http://www.haskell.org/ghc/dist/current/dist/ghc-6.5.20060901-i386-unknown-mingw32.tar.gz http://www.haskell.org/ghc/dist/stable/dist/ghc-6.4.2.20060609-i386-unknown-mingw32.tar.gz after program prints 40 mb allocated look at Task Manager indication - it shows that two times more memory actually in use. it seems that problem is only with allocating memory buffers whose sizes are powers of 2 or very close - bug shows for bufsize = 4kb, 1mb or 4095, but not not for 4000 or 10^6 -- Best regards, Bulat mailto:[EMAIL PROTECTED] mallocForeignPtrBytes.hs Description: Binary data ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: bug in mallocForeignPtrBytes (both 6.4 and 6.6)
On Sat, 2006-09-23 at 13:58 +0400, Bulat Ziganshin wrote: Hello glasgow-haskell-users, the attached program show up the bug in mallocForeignPtrBytes (and newPinnedByteArray#) implementation - it allocates two times more memory as requested. The bug seen both on 6.6rc and june 6.4 windows builds, namely: http://www.haskell.org/ghc/dist/current/dist/ghc-6.5.20060901-i386-unknown-mingw32.tar.gz http://www.haskell.org/ghc/dist/stable/dist/ghc-6.4.2.20060609-i386-unknown-mingw32.tar.gz after program prints 40 mb allocated look at Task Manager indication - it shows that two times more memory actually in use. it seems that problem is only with allocating memory buffers whose sizes are powers of 2 or very close - bug shows for bufsize = 4kb, 1mb or 4095, but not not for 4000 or 10^6 The reason for this is that for larger objects ghc has an allocation granularity of 4k. That is it always uses a multiple of 4k bytes. However a byte array has some overhead: it needs one word for the heap cell header and another for the length. So if you allocate a 4k byte array then it uses 8k. So the trick is to allocate 4k - overhead. This is what the Data.ByteString library does. Duncan ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: User preferences lost between Hugs upgrades on Windows
[some possibly shared hugs/ghci concerns] The settings on Windows are stored under a registry key for each specific release. This means that if you install WinHugs, carefully set up everything, then upgrade, you loose all your settings. part of the reason was also to enable multiple independent versions of Hugs to be installed, I think? So: a) shouldn't there be a way from within Hugs (or GHCi) to export/import settings? b) shouldn't there be an installation option checking for compatible old settings and offering to copy them? c) given the move towards cabal, shouldn't there be a way for new Hugs/GHC installs to take over existing library install setups (provided that the libraries sources haven't been removed, and that the rebuild is possible with the new Haskell implementation)? while on the subject of user preferences, does the current round of Hugs/GHC releases on Windows do away with that we take over the handling of Haskell files, no matter what the user wanted? - it's a pain to have Hugs and GHCi compete with each other on this - I don't want either to be the default handler for .hs/.lhs files; not only do I tend to have several versions of Haskell implementations installed at any time (usually including 2 ghcs), I want Haskell files to open in my favourite editor, not in any of those Haskell implementations (and no, going via WinHugs :e is not an option, eg when browsing files from some darcs repo on the web) any chance of Haskell implementations being less greedy and more cooperative on Windows this time round?-) cheers, claus ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: User preferences lost between Hugs upgrades on Windows
Hi, a) shouldn't there be a way from within Hugs (or GHCi) to export/import settings? That can be added, but no one will use it - too much effort, not obvious thats what needs to be done. b) shouldn't there be an installation option checking for compatible old settings and offering to copy them? Reasonable, although I still think just having one set of settings is a better way forward. c) given the move towards cabal, shouldn't there be a way for new Hugs/GHC installs to take over existing library install setups (provided that the libraries sources haven't been removed, and that the rebuild is possible with the new Haskell implementation)? A cabal issue, since Hugs has no knowledge of Cabal, but a reasonable idea. while on the subject of user preferences, does the current round of Hugs/GHC releases on Windows do away with that we take over the handling of Haskell files, no matter what the user wanted? Nope :) I emailed off to people about this offering to cooperate nicely with GHC and Hugs, but no one ever got back to me, so both WinHugs and GHC steal the preferences. GHC also replaces the .hs document icon with one that is more ugly. I tried to submit a patch, and have emailed over the icons, but the GHC installer stuff isn't publically available, so I have no way to fix it. - I don't want either to be the default handler for .hs/.lhs files; not only do I tend to have several versions of Haskell implementations installed at any time (usually including 2 ghcs), I want Haskell files to open in my favourite editor, not in any of those Haskell implementations (and no, going via WinHugs :e is not an option, eg when browsing files from some darcs repo on the web) Have you used a recent copy of WinHugs? The default action is to open the file in WinHugs, but there is also an edit action which opens the file in whichever editor you have configured WinHugs to use. It does this by firing off WinHugs, checking your settings for the best haskell editor, and starting it. If you haven't configured any editor specially, it will find the editor that seems best - i.e. if you have TextPad and Notepad, it will pick TextPad, otherwise it will pick Notepad if thats all it can find. All very seamless. I'd love to make Edit be the default, i.e. rename it to Open, and then add Open with WinHugs. However, this is a change in how WinHugs operates. Initially I tried to adhere quite closely to how WinHugs worked before I hacked on it, now I think the time has come to have Open be Edit and add Open in WinHugs. any chance of Haskell implementations being less greedy and more cooperative on Windows this time round?-) This time around, no - you just missed the boat on WinHugs and you're probably too late for GHC 6.6. Next time around, perhaps. I'm willing to do the WinHugs side, but it does need someone to do the GHC side. This is especially important because (as far as I was able to make out last time I started asking questions), the GHC installer is generated with a proprietory Haskell script which is not publically available. This means the community cannot play with the GHC installer and fix these issues. I am willing to adapt the Hugs on Windows installer to GHC, if thats something the GHC team would rather? You could also then have nightly builds that included an installer. For reference, Yhc is moving to the Hugs installer, and the Yhc nightly builds will come with an installer. For the moment Yhc won't register any file extensions, but if some suitable agreement can be found, I'll make sure Yhc follows that. Thanks Neil ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell] MR details (was: Implicit type of numeric constants)
Hello, I don't take my advice to go to haskell-cafe :-) The discussion continued outside the mailing list, and now I have two questions myself: 1. Why do the rules of the monomorphism restriction explicitly mention *simple* pattern bindings? Where is the difference, especially as there is a translation to simple pattern bindings? Why should p | a==b = 2 | otherwise = 3 be treated different than p = if a==b then 2 else 3 2. The gentle introduction says in section 12.3: An identifier is monomorphic if is either not overloaded, or is overloaded but is used in at most one specific overloading and is not exported. How does that relate to the report? Maybe I have to withdraw what I said about haskell being well defined. All the best Christian Sievers ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Performance, Optimization and Code Generation
This starts out with my being interested in darcs - git related issues. Since git uses sha1 I wanted to have the ability to calculate sha1 in an application where I was intending to use darcs as a back-end. The performance gap is * 30 between Haskell and sha1sum. That seemed rather steep and so I started looking... Using ghc 6.4.2 The following code is from SHA1: -- {-# INLINE step #-} step :: ABCDE - BS.ByteString - ABCDE step abcde0@(ABCDE a b c d e) words = abcde5 where s16 = get_word_32s words s80 = s16 ++ (zipWith4 f0) (drop 13 s80) (drop 8 s80) (drop 2 s80) s80 f0 a b c d = rotL (a `xor` b `xor` c `xor` d) 1 (s20_0, s60) = splitAt 20 s80 (s20_1, s40) = splitAt 20 s60 (s20_2, s20) = splitAt 20 s40 (s20_3, _) = splitAt 20 s20 abcde1 = foldl (doit f1 0x5a827999) abcde0 s20_0 abcde2 = foldl (doit f2 0x6ed9eba1) abcde1 s20_1 abcde3 = foldl (doit f3 0x8f1bbcdc) abcde2 s20_2 ABCDE a' b' c' d' e' = foldl (doit f2 0xca62c1d6) abcde3 s20_3 f1 (XYZ x y z) = (x .. y) .|. ((complement x) .. z) f2 (XYZ x y z) = x `xor` y `xor` z f3 (XYZ x y z) = (x .. y) .|. (x .. z) .|. (y .. z) abcde5 = ABCDE (a + a') (b + b') (c + c') (d + d') (e + e') -- {-# INLINE get_word_32s #-} get_word_32s :: BS.ByteString - [Word32] get_word_32s s = map f [0..15] where f i = foldl (+) 0 $ map (\n - toEnum (fromEnum (BS.index s (i*4+n))) `shiftL` (8 * (3-n))) [0..3] -- {-# INLINE doit #-} doit :: (XYZ - Word32) - Word32 - ABCDE - Word32 - ABCDE doit f k (ABCDE a b c d e) w = ABCDE a' a (rotL b 30) c d where a' = rotL a 5 + f (XYZ b c d) + e + w + k -- {-# INLINE rotL #-} rotL :: Word32 - Rotation - Word32 rotL a s = shiftL a s .|. shiftL a (s-32) -- rotL a s = a `seq` rotate a s I want to focus on the rotL function --- get_word_32s might be faster with a rewrite. Using -prof -auto-all and -P at runtime produced the following summary... COST CENTRE MODULE %time %alloc ticks bytes get_word_32s MySHA1 39.3 35.0 10597 6952614960 rotL MySHA1 22.6 18.5 6089 3682275072 step MySHA1 21.2 24.1 5701 4783669848 doit MySHA1 16.2 21.8 4362 4332088320 As part of a larger program, but the sha1 portion was where 98% of the time went. So I tried using the built-in "rotate", I tried inlining, I tried using -fasm directly I tried generating C with -O2, I tried using 'seq' in a number of places. None of this made much difference. Comment, the C code for just rotL would be unsigned int rotate(unsigned int a, int b) { return (a b) | (a (b - 32)); } and the assembler at gcc -O2 is concise and straightforward: .file "rotate.c" .text .p2align 4,,15 .globl rotate .type rotate, @function rotate: pushl %ebp movl %esp, %ebp movl 8(%ebp), %edx movl 12(%ebp), %ecx popl %ebp movl %edx, %eax sall %cl, %eax subl $32, %ecx shrl %cl, %edx orl %edx, %eax ret .size rotate, .-rotate .section .note.GNU-stack,"",@progbits .ident "GCC: (GNU) 3.3.5 (Debian 1:3.3.5-3)" GHC's code on this part is nothing like competitive because of the need for closures --- I think. 1) What approaches to getting the compiler to optimize have I overlooked? Or, how would you change the code to get the compiler to generate better code for rotL? 2) Am I missing an easy way to get strictness on the rotL function? 3) Is there something I am missing that keeps ghc's code from becoming about as concise as gcc -O2? 4) Is the code generator simply not able to handle this? Thanks in advance, George ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Performance, Optimization and Code Generation
according to http://darcs.haskell.org/packages/base/GHC/Word.hs, GHC's rotate is implemented as (W32# x#) `rotate` (I# i#) | i'# ==# 0# = W32# x# | otherwise = W32# ((x# `shiftL32#` i'#) `or32#` (x# `shiftRL32#` (32# -# i'#))) where i'# = word2Int# (int2Word# i# `and#` int2Word# 31#) So you can see that it takes i modulo 32 first (by anding it with 31). Perhaps one needs an uncheckedRotate32# function (if it doesn't exist). Also, shouldn't the calls to shiftL32# and shiftRL32# be calls to uncheckedShiftL32# and uncheckedShiftR32# since i'# and (32# -# i'#) are provably safe? -- Russell O'Connor http://r6.ca/ ``All talk about `theft,''' the general counsel of the American Graphophone Company wrote, ``is the merest claptrap, for there exists no property in ideas musical, literary or artistic, except as defined by statute.'' ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] ANNOUNCE: Dr Haskell 0.1
Hi Haskell, This is the first release of Dr Haskell, a tool to help suggest improvements to your code. GETTING DR HASKELL See http://www-users.cs.york.ac.uk/~ndm/projects/drhaskell.php for details on how to download and install the program. There are prebuilt Windows binaries. This project requires Yhc to be installed and working, of which there are also prebuilt binaries (see the above web page for pointers). This program should work fine on Linux/Mac etc, provided you first have Yhc installed. AN EXAMPLE SESSION Imagine you have a program, and somewhere deep inside the program it has the expression: take 5 (repeat '!') An experienced Haskell user might realise that this is in fact replicate, but a beginner has no way of discovering this function for themselves, besides reading the standard libraries! Put that definition in a Haskell source file, say Test.hs, then run: drhaskell Test.hs I can apply use_replicate in check_elem (5:10-6:80) Dr Haskell gives a suggestion (use_replicate) to a specific function (check_elem) and a given source location (line 5, column 10) Of course, they might have written take 5 $ repeat '!', or take n . repeat, or quite a few other variations. Dr Haskell can see through these things nicely. Of course, Dr Haskell can make more powerful suggestions, for example: if f x then 4 else if g x then 4 else primes !! 10 And Dr Haskell will suggest you use f x || g x instead The hints are isolated from the program, and can be easily changed by the user. More hint patches are most welcome. See http://www.cs.york.ac.uk/fp/darcs/drhaskell/Hints.hs for a list of the hints currently available in the code. LIMITATIONS Requires a working copy of Yhc. You must first have your program/file successfully compiling with Yhc. Once you have got over the admin side (compiling etc, invoking correctly), the actual hint algorithm is pretty robust. Bug reports/suggestions/patches most welcome. YHC INFORMATION Home page: http://haskell.org/haskellwiki/Yhc Build details: http://haskell.org/haskellwiki/Yhc/Building Windows snapshot: http://haskell.org/haskellwiki/Yhc/Snapshots If Yhc won't build for you, or you have other difficulties, please bug the Yhc Team on their mailing list, yhc -at- haskell -dot- org. Thanks Neil ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re[2]: [Haskell] Performance, Optimization and Code Generation
Hello roconnor, Saturday, September 23, 2006, 4:13:39 PM, you wrote: Also, shouldn't the calls to shiftL32# and shiftRL32# be calls to uncheckedShiftL32# and uncheckedShiftR32# since i'# and (32# -# i'#) are provably safe? yes. below is the code used in my lib: #ifdef __GLASGOW_HASKELL__ (I# a) # (I# b) = (I# (a `iShiftL#` b)) (I# a) # (I# b) = (I# (a `uncheckedIShiftRL#` b)) #else /* ! __GLASGOW_HASKELL__ */ a # b = a `shiftL` b a # b = a `shiftR` b #endif /* ! __GLASGOW_HASKELL__ */ -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] BitSyntax for Haskell
Erlang's bit syntax[1] is a great for building and breaking up binary structures. I've knocked up something similar (although a little clumsy) for Haskell: http://www.imperialviolet.org/binary/bitsyntax/ http://www.imperialviolet.org/binary/bitsyntax/BitSyntax.hs I'm sure that this isn't the best possible way to do this, but it suffices at this stage for many problems. [1] http://www.erlang.org/doc/doc-5.4.12/doc/programming_examples/bit_syntax.html -- Adam Langley [EMAIL PROTECTED] ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: Here-docs in Haskell source
On Fri, Sep 22, 2006 at 12:39:34PM -0400, Ian Zimmerman wrote: If you do this at all, reuse the regular quotes, don't invent yet another weird and wonderful lexical syntax. Haskell is already bad enough that way, with \ used for lambda and so on. @ would be okay I guess. Why not just go the Python way and use ? That is, three literal quotes at the beginning and end. After all, Python has lifted quite a few things from Haskell. Time to return the favor. ;-) ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Here-docs in Haskell source
I would also like to see these. I like the python syntax stuff... but really most anything will do. the triple quote doesn't eat any usable syntax though and won't require any special cases in the parser so I would much prefer something like that. John -- John Meacham - ⑆repetae.net⑆john⑈ ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Here-docs in Haskell source
Ian If you do this at all, reuse the regular quotes, don't invent yet Ian another weird and wonderful lexical syntax. Haskell is already bad Ian enough that way, with \ used for lambda and so on. @ would be Ian okay I guess. John Why not just go the Python way and use ? That is, three John literal quotes at the beginning and end. After all, Python has John lifted quite a few things from Haskell. Time to return the John favor. ;-) Because it will confuse language-agnostic tools. Do you use Emacs? How does it handle the Python syntax? I am not a Python programmer, so I can't answer that myself. But I'll hazard a guess: badly. -- She had a passion for anyone who could do anything really well. ...Not for an engineer, not for a technician! Mikhail Bulgakov, The Master Margarita ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Here-docs in Haskell source
On Fri, Sep 22, 2006 at 09:30:50PM -0400, Ian Zimmerman wrote: John Why not just go the Python way and use ? That is, three John literal quotes at the beginning and end. After all, Python has John lifted quite a few things from Haskell. Time to return the John favor. ;-) Because it will confuse language-agnostic tools. I don't understand -- what language-agnostic tools would this confuse more than any other syntax? Do you use Emacs? How does it handle the Python syntax? I am not a Python programmer, so I can't answer that myself. But I'll hazard a guess: badly. python-mode actually handles Python syntax a lot better than haskell-mode handles Haskell syntax, particularly regarding indentation. -- John ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Here-docs in Haskell source
John python-mode actually handles Python syntax a lot better than John haskell-mode handles Haskell syntax, particularly regarding John indentation. Automatic indentation is only one aspect of Emacs modes, and as far as I am concerned not nearly the most important one. Here's a quick test: put the cursor in front of a triple-quoted string, then hit Control-Alt-F (forward-sexp). It should move just after the whole string. Does it? Any tool which assumes strings are delimited by a single front delimiter and a single end delimiter, which they are in most reasonable languages, will have trouble. -- She had a passion for anyone who could do anything really well. ...Not for an engineer, not for a technician! Mikhail Bulgakov, The Master Margarita ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Here-docs in Haskell source
On 22 Sep 2006 23:54:42 -0400, Ian Zimmerman [EMAIL PROTECTED] wrote: Here's a quick test: put the cursor in front of a triple-quoted string, then hit Control-Alt-F (forward-sexp). It should move just after the whole string. Does it? Any tool which assumes strings are delimited by a single front delimiter and a single end delimiter, which they are in most reasonable languages, will have trouble. (just speculating here...) In order to produce one double-quote inside a double-quote delimited string, many (most?) languages let you use two adjacent double quotes. So a string starting with triple double-quote would result in a string that has one double quote as its first char. I imagine that smarter language-aware editors would handle this case, otherwise they would not correctly recognise whether or not the cursor was inside a string literal. Alistair ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Here-docs in Haskell source
Alistair In order to produce one double-quote inside a double-quote Alistair delimited string, many (most?) languages let you use two Alistair adjacent double quotes. So a string starting with triple Alistair double-quote would result in a string that has one double Alistair quote as its first char. Alistair I imagine that smarter language-aware editors would handle Alistair this case, otherwise they would not correctly recognise Alistair whether or not the cursor was inside a string literal. Hmm, you're right. I myself know of only one such language, Pascal (and its derivatives, such as Ada), but Pascal should definitely be handled by Emacs. I'll have to take a look at the Pascal mode to see how they do it. Still, I prefer the other syntax :-) (single double quotes with a pseudo operator prefix). -- She had a passion for anyone who could do anything really well. ...Not for an engineer, not for a technician! Mikhail Bulgakov, The Master Margarita ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Here-docs in Haskell source
On Fri, Sep 22, 2006 at 11:54:42PM -0400, Ian Zimmerman wrote: John indentation. Automatic indentation is only one aspect of Emacs modes, and as far as I am concerned not nearly the most important one. Here's a quick test: put the cursor in front of a triple-quoted string, then hit Control-Alt-F (forward-sexp). It should move just after the whole string. Does it? Yes, it does. But I don't think we should be limiting our language by what Emacs does. Any tool which assumes strings are delimited by a single front delimiter and a single end delimiter, which they are in most reasonable languages, will have trouble. Then the tools are buggy. What sort of tools are you thinking of here? ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Here-docs in Haskell source
Hi Any tool which assumes strings are delimited by a single front delimiter and a single end delimiter, which they are in most reasonable languages, will have trouble. In current haskell any tool which assumes characters start and end with a ' are also wrong, because you can have name' as a function name etc. My editor is one of these, I accepted it, turned off character syntax hilighting and moved on. As a side note, perhaps if you're shoving massive amounts of text into a Haskell source file you want to either move to something more structured (like haskell source extensions), or if it really is just some large constant, then put it in a separate file. Thanks Neil ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: [Haskell-cafe] Why am I not allowed to use CStringLen inforeignexport?
Andreas Marth wrote: low_l :: Word8 = fromIntegral (len .. 0x) low_h :: Word8 = fromIntegral (shiftR len 8 .. 0x) high_l :: Word8 = fromIntegral (shiftR len 16 .. 0x) high_h :: Word8 = fromIntegral (shiftR len 24 .. 0x) Hi - I just noticed the mask should be changed to 0xFF for the BSTR8 version above. Also, I'm not actually sure if a mask is needed at all. I just used one to make sure there would be no chance of an overflow exception being thrown, but the Haskell report doesn't seem to specify anything at all about the behaviour of (fromIntegral) when converting between types of different sizes. Perhaps someone on the list can clarify whether or not a mask is needed ie is fromIntegral allowed to throw exceptions or does it always just silently discard unwanted bits of the argument being converted? Thanks, Brian. -- Logic empowers us and Love gives us purpose. Yet still phantoms restless for eras long past, congealed in the present in unthought forms, strive mightily unseen to destroy us. http://www.metamilk.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Trying to write a TCP proxy
John Ky wrote: I finally realised that hGetLine strips out the \n newline character so when I forward the line to the server, I need to append it again. Or use hPutStrLn instead of hPutStr ? (I may be missing something...) Bye Christian Sievers ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell Program
The company I work for was gracious enough to allow me to release a haskell program I wrote for them: http://www.isecpartners.com/file_fuzzers.html There's a python version and a rewrite in haskell. I used some looping constructs discussed earlier on this list to keep the haskell code similar to its original python code. Don Stewart was kind enough to help me optimize some of the code using ByteString and a faster PRNG (the System.Random class seems to be a bit on the slow side!). Prior to using ByteString and optimizing the code it was a bit slower than the python version, but with optimizations it is quite a bit faster. (In practice, the external program being invoked is usually the performance bottleneck). Tim Newsham http://www.thenewsh.com/~newsham/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Polymorphism/monomorphism (and the restriction)
Aaron McDaid wrote: This code experiments with Int, Float and (Num a) = a, and I tried to print x*2 and x/2 for each. (4::Int)/2 isn't allowed because / isn't defined for Ints. More exactly: (/) is a member function of the Fractional class, and Int is not an instance of this class. You can see that kN :: (Num a) = a took two different types depending on what method ( / or * ) was applied to it. kN / 2 = 2.0 kN * 2 = 8 kN/2 is a Float (it can't use Int as / isn't defined for Int, so it uses Float, for which / is defined). kN/2 has type Fractional a = a (try :t kN/2 in ghci) and when you apply it to show, a specific type will be chosen by defaulting (Haskell report section 4.3.4). Without an explicit default declaration, Haskell will try first Integer, then Double. Integer is not an instance of Fractional, so Double will be used. You will get the types you claim to get when you add the line default (Int,Float) at the top of your file. kN*2 is an Int. By itself, it's Num a = a, then it will default to Integer. The above outputs demonstrates polymorphism, doesn't it? i.e. Not only Polymorphism (or rather: overloading) and defaulting. has the compiler got a variety of types to choose from, but a variety of types can be used at runtime? It only chooses (i.e. tries in order) the types given in the (posibly implicit) default declaration. At runtime it doesn't care about types, but of course the same polymorphic or overloaded function can be used with different types. The interesting thing is that k behaves as a Float in both cases. This is monomorphism isn't it? i.e. the compiler may have a variety of types to choose from, but it picks one and sticks to it for every usage. In summary, k didn't give the same outputs as kN. Since (/) is used with k, it must be Fractional, so as in kN/2, defaulting makes it Double. I'm fairly new to these lists, so apologies if I'm covering old ground again. My first aim is to understand exactly what polymorphism and monomorphism is and demonstrate corresponding results, before thinking about the restriction. The type of map :: (a - b) - [a] - [b] is polymorphic. Here we are talking about overloading, also known as ad-hoc polymorphism. In Haskell overloaded functions are recognizable by the context in their type, e.g.: abs :: Num a = a - a I think I also mixed this up in one of my earlier mails. Seems we need a glossary. Bye Christian Sievers ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [newbie] How to test this function?
Bruno Martínez [EMAIL PROTECTED] writes: On Thu, 21 Sep 2006 15:12:07 -0300, Benjamin Franksen [EMAIL PROTECTED] wrote: OK. Thanks. I didn't find that one because it's not offered as an identation option in emacs haskell mode. Emacs is evil! David House wrote: I'll ignore the throwaway flaimbait there ;) Jón Fairbairn wrote: That's a great exaggeration Of course. I am sorry, couldn't resist the urge, if you know what I mean. Oh and forgot the ubiquitous smiley, so here goes: ;-) Cheers, Ben ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell.org down
Just in case it has gone unnoticed, haskell.org seems to have been down for a few hours now. Do we have an admin looking into this? -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] Why am I not allowed to use CStringLen inforeignexport?
Hello Brian, Friday, September 22, 2006, 9:03:01 PM, you wrote: withBSTR8 :: [Char] - (BSTR8 - IO a) - IO a withBSTR8 s f = bracket (createBSTR8 s) (\bstr - free (bstr `plusPtr` (-4))) (\bstr - f bstr) this may be shortened to withBSTR8 s = bracket (createBSTR8 s) (\bstr - free (bstr `plusPtr` (-4))) my lib contains a tons of such brackets -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [Haskell] MR details (was: Implicit type of numeric constants)
On 23/09/2006, at 4:33 AM, Christian Sievers wrote: Hello, I don't take my advice to go to haskell-cafe :-) I will take your advice :) The discussion continued outside the mailing list, and now I have two questions myself: 1. Why do the rules of the monomorphism restriction explicitly mention *simple* pattern bindings? Where is the difference, especially as there is a translation to simple pattern bindings? Why should p | a==b = 2 | otherwise = 3 be treated different than p = if a==b then 2 else 3 They are the same (both are simple pattern bindings). The report says in section 4.4.3.2 that the first can be translated into the second. A simple pattern binding is one where the lhs is a variable only. If a pattern binding is not simple, it must have a data constructor on the lhs, therefore it cannot be overloaded. So the (dreaded) MR only applies to simple pattern bindings. Cheers, Bernie. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell.org down
Thanks Don. I alerted our IT staff this morning, and they seem to have things working again, although here is their final response: The web server had over 150 client connections which exceeded its limit. I restarted the web server and all is well. I'll keep and eye on it and see if someone is trying a denial of server attack, or it could be you need a newer faster machine. :-) So either Haskell is getting really popular (on a Friday night?) or there's something fishy going on. -Paul Donald Bruce Stewart wrote: Just in case it has gone unnoticed, haskell.org seems to have been down for a few hours now. Do we have an admin looking into this? -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Program
Cool! Were you going to tell us what the program does, or are we supposed to read the source and figure it out? From the web page: File Fuzzers These tools are useful for testing any program which processes binary file inputs such as archivers and image file viewers. FileP is a python-based file fuzzer. It generates mutated files from a list of source files and feeds them to an external program in batches. Prerequisites: Python 2.4 FileH is a haskell-based file fuzzer. It generates mutated files from a list of source files and feeds them to an external program in batches. Prerequisites: GHC 6.4.2 Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [newbie] How to test this function?
First, how do I fix the identation of the if then else? getList = find 5 where find 0 = return [] find n = do ch - getChar if ch `elem` ['a'..'e'] then do tl - find (n-1) return (ch : tl) else find n OK. Thanks. I didn't find that one because it's not offered as an identation option in emacs haskell mode. It's not just a missing option, it's a bug. I'll hopefully get around to fixing it soon. Emacs is evil! Of course, that's why we like it so much. It also inserts random tab characters into your code just to save a few space bytes. Actually, it has nothing to do with saving space: it only uses TABs because many people *want* to use tabs. Of course, the rest of the users *doesn't want* to use tabs, so we get to be flogged both ways. BTW, when was the last time you tried haskell-mode? Haskell-mode (at least since version 2.0) makes it difficult for the user to insert TABs by mistake. Tends to completely trash indentation e.g. when pasting code into mails etc. Huh? You mean your mail reader doesn't display tabs in the same way as 8 spaces? TABs are evil for many reasons, but I've never seen this one. Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: [Haskell] MR details (was: Implicit type of numeric constants)
On 9/23/06, Bernie Pope [EMAIL PROTECTED] wrote: If a pattern binding is not simple, it must have a data constructor on the lhs, therefore it cannot be overloaded. So the (dreaded) MR only applies to simple pattern bindings. I thought it was simple pattern bindings that could be *exempted* from the MR by supplying an explicit type signature, while non-simple pattern bindings are always subject to it. Mike ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [newbie] How to test this function?
For that one, if it doesn't get mended for long enough, Haskell' might accept the present layout. http://hackage.haskell.org/trac/haskell-prime/wiki/DoAndIfThenElse Hmm... the bug in haskell-mode has been known for almost a year now. So you're saying that I should just wait even more and it'll get fixed by Haskell'? IOW Haskell isn't just lazy but it even rewards laziness? Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: [Haskell] MR details (was: Implicit type of numeric constants)
On 24/09/2006, at 1:46 AM, Michael Shulman wrote: On 9/23/06, Bernie Pope [EMAIL PROTECTED] wrote: If a pattern binding is not simple, it must have a data constructor on the lhs, therefore it cannot be overloaded. So the (dreaded) MR only applies to simple pattern bindings. I thought it was simple pattern bindings that could be *exempted* from the MR by supplying an explicit type signature, while non-simple pattern bindings are always subject to it. Actually, I realised after I posted my message that what I wrote was dubious. I'm sorry about that, please ignore it. This section from the Report seems to clear things up: In Motivation, section 4.5.5: Rule 1 prevents ambiguity. For example, consider the declaration group [(n,s)] = reads t Recall that reads is a standard function whose type is given by the signature reads :: (Read a) = String - [(a,String)] Without Rule 1, n would be assigned the type forall a. Read a =a and s the type forall a. Read a =String. The latter is an invalid type, because it is inherently ambiguous. It is not possible to determine at what overloading to use s, nor can this be solved by adding a type signature for s. Hence, when non-simple pattern bindings are used (Section 4.4.3.2), the types inferred are always monomorphic in their constrained type variables, irrespective of whether a type signature is provided. In this case, both n and s are monomorphic in a. Sorry for the confusion, Bernie. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] variadic functions and typeCast
Hi all, I am writing, for my own amusement, a more general version of the trick to implement variadic functions in Haskell outlined at http://okmij.org/ftp/Haskell/vararg-fn.lhs. (If someone else has done this already, please point me to it!) Code is attached at the end of the message. My question concerns the use of `typeCast', which is defined as follows: class TypeCast x y | x - y, y - x where typeCast :: x - y instance TypeCast x x where typeCast = id This is taken from the paper Strongly typed heterogeneous collections by Oleg Kiselyov, Ralf Lammel, and Keean Schupke. As observed there, the TypeCast instance declaration must occur in a separate module; otherwise the compiler is too eager about type simplification. (I also get the same errors if VarArg is interpreted by GHCi, even if TypeCast is in a separate module.) I think I understand the reason for this, but I find it a little surprising; it wasn't clear to me from the documentation that fundeps introduce a new dependence on module boundaries. Anyway, my main question about typeCast is this: why is it needed here at all? If I omit it entirely, the code compiles fine, but then using it gives error messages like the following: Prelude VarArg build 'h' 'i' :: String interactive:1:0: No instances for (VarFold [a] [a] [Char], VarAccum Char [a]) arising from use of `build' at interactive:1:0-4 ... I don't understand why the type-checker is unable to infer that the type variable `a' should be specialized to `Char' here, since the only available instance of VarFold whose third type is [Char] has the first type also being [Char]. I've given the compiler all the type hints I can think of. Can someone explain this to me? I should say that if I add a functional dependency l - a to the class VarAccum, then this particular example works. However, I have other examples in mind for which l doesn't functionally determine a, so I don't want to do that. And I don't see why it's necessary. Here's the code: class VarAccum a l where accum :: a - l - l class VarFold b l r where varFold :: (l - b) - l - r instance (TypeCast b c) = VarFold b l c where varFold f xs = typeCast (f xs) instance (VarFold b l r, VarAccum a l) = VarFold b l (a - r) where varFold f xs x = varFold f (accum x xs) -- This is the type of variadic functions from lots of As to a B. type a :-- b = forall r. (VarFold b [a] r) = r infixr 0 :-- instance VarAccum a [a] where accum x xs = (x:xs) varArg :: forall a b. ([a] - b) - (a :-- b) varArg f = varFold (f . reverse) ([] :: [a]) build :: forall a. a :-- [a] build = varArg (id :: [a] - [a]) Thanks! Mike ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Unable to profile program using Data.ByteString.Lazy
Hi folks, I wrote a program that uses some of the Data.ByteString libraries. I'm using GHC 6.4.1 and FPS 0.7. The program compiles and works just fine. But when I try to profile it, by compiling with -prof, I get: Failed to load interface for `Data.ByteString.Lazy': Could not find module `Data.ByteString.Lazy': locations searched: Data/ByteString/Lazy.hi Data/ByteString/Lazy.hi-boot /f/g/lib/fps-0.7/Data/ByteString/Lazy.p_hi Why can it find the module when it's compiling without -prof, but not when it's compiling with it? I would really like to get profiling to work. Thanks, Lyle ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Unable to profile program using Data.ByteString.Lazy
lists: Hi folks, I wrote a program that uses some of the Data.ByteString libraries. I'm using GHC 6.4.1 and FPS 0.7. The program compiles and works just fine. But when I try to profile it, by compiling with -prof, I get: Failed to load interface for `Data.ByteString.Lazy': Could not find module `Data.ByteString.Lazy': locations searched: Data/ByteString/Lazy.hi Data/ByteString/Lazy.hi-boot /f/g/lib/fps-0.7/Data/ByteString/Lazy.p_hi Why can it find the module when it's compiling without -prof, but not when it's compiling with it? I would really like to get profiling to work. Probably you didn't build fps with profiling as well? You can rebuild fps with: runhaskell Setup.hs configure -p as the first step. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] FFI and LD_PRELOAD - segfault
Hi, I'm trying to use a shared lib written in Haskell to overload C functions via LD_PRELOAD. You might think this is a bit silly, but hey, why not? I want to overload connect() from sys/socket.h. I'll document what I've written so far; unfortunately there doesn't seem to be a lot of documentation about this topic. This is my haskell code (in testffi.hs): module Socks where import Foreign.C.Types import Foreign.Ptr newtype S_sockaddr = S_sockaddr () foreign export ccall connect connect :: CInt - Ptr (S_sockaddr) - CUInt - IO CInt connect :: CInt - Ptr (S_sockaddr) - CUInt - IO CInt connect _ _ _ = return (-1::CInt) Here's how I compile it: ghc -Wall -c -fffi testffi.hs ghc -Wall -optl -shared -optl -Wl,-soname,libtestffi.so \ -o libtestffi.so testffi.o testffi_stub.o I'm not at all sure about these compiler and linker options, but this is the best I could come up with (i.e., no errors or warnings) Then I run a test program which calls connect(). I won't include the C source of that program, but it basically connects to the IP address given as the first argument (at port given by third argument) and sends a string. Basic error checking is done, i.e. the program does test the return value of connect(): LD_PRELOAD=./libtestffi.so ./conntest 127.0.0.1 HELO 1234 This aborts with a segfault in scheduleWaitThread() from ./libtestffi.so The test program doesn't use threads, so I'm wondering what I did wrong? Any help is appreciated. Greetings, Stephan Walter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell.org down
On Sat, 2006-09-23 at 09:58 -0400, Paul Hudak wrote: Thanks Don. I alerted our IT staff this morning, and they seem to have things working again, although here is their final response: The web server had over 150 client connections which exceeded its limit. I restarted the web server and all is well. I'll keep and eye on it and see if someone is trying a denial of server attack, or it could be you need a newer faster machine. :-) So either Haskell is getting really popular (on a Friday night?) or there's something fishy going on. I've noticed this happen several times in the past. It would have 150 hung connections but not very high cpu or network usage. On those occasions I restated httpd to get things going again. Looking at the httpd access logs it looked to me like an errant indexing bot. One example of something we might want to ban bots from is from accessing all past revisions and diffs of wiki pages. But generally we probably just need to look at the logs and try and see what's going on. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell.org down
I have been linked before on slashdot to my humble web server (all 333MHz of awesome CPU power). I can attest to the effect that you are describing. Tony Morris http://tmorris.net/ Tomasz Zielonka wrote: On Sat, Sep 23, 2006 at 06:03:41PM +0200, Tomasz Zielonka wrote: Yesterday there was a link to haskell.org on reddit.com, precisely to http://haskell.org/haskellwiki/Simple_unix_tools . The server experienced something like a slashdot effect. On the other hand, I think haskell.org was linked from reddit before and I don't remember similar problems. Perhaps reddit got more popular or the link was also put on other similar sites. Best regards Tomasz ___ 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[2]: [Haskell-cafe] Haskell.org down
Hello Paul, Saturday, September 23, 2006, 5:58:02 PM, you wrote: So either Haskell is getting really popular (on a Friday night?) or there's something fishy going on. are you sure that all haskellers live in England? ;) -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell.org down
paul.hudak: Thanks Don. I alerted our IT staff this morning, and they seem to have things working again, although here is their final response: The web server had over 150 client connections which exceeded its limit. I restarted the web server and all is well. I'll keep and eye on it and see if someone is trying a denial of server attack, or it could be you need a newer faster machine. :-) So either Haskell is getting really popular (on a Friday night?) or there's something fishy going on. Hmm. Looks like its gone down again? Seems fishy... -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe