[Haskell-cafe] ANN: BUG FIX release of regex-tdfa-1.1.2

2009-05-05 Thread ChrisK
Hello, While occasionally and slowly updating the future version of regex-tdfa I found a bug that exists in the released 1.1.1 version. It was just a matter of passing the wrong value into a function, so was easy to fix when I figured it out. The test case triggered an impossible error

[Haskell-cafe] Re: Parallel combinator, performance advice

2009-04-07 Thread ChrisK
You create one MVar for each task in order to ensure all the tasks are done. This is pretty heavyweight. You could create a single Control.Concurrent.QSemN to count the completed tasks, starting with 0. Each task is followed by signalQSemN with a value of 1. (I would use finally). As

[Haskell-cafe] Re: Parallel combinator, performance advice

2009-04-07 Thread ChrisK
Neil Mitchell wrote: Sorry, accidentally sent before finishing the response! I also noticed you sent this directly to me, not to -cafe, was that intentional? The mail/news gateway makes it look like that, but I also sent to the mailing list. You mean something like: parallel_ xs = sem

[Haskell-cafe] Re: Parallel combinator, performance advice

2009-04-07 Thread ChrisK
Neil Mitchell wrote: I guess the nested calls to parallel_ bit is the part of the spec that makes everything much harder! Thanks Neil Yes. Much more annoying. But the problem here is generic. To avoid it you must never allow all thread to block at once. The parallel_ function is

[Haskell-cafe] Re: Use unsafePerformIO to catch Exception?

2009-03-23 Thread ChrisK
You should ensure that the result of evaluate is in normal form, not just weak head normal form. You can do this with the Control.Parallel.Strategies module: import Control.Exception(ArithException(..),try,evaluate) import Control.Parallel.Strategies(NFData,using,rnf) import

[Haskell-cafe] ANN: regex-tdfa 1.1.1

2009-03-22 Thread ChrisK
This is both a bug fix release and a feature release. The bug fix is a bit embarrassing, the indices were correct but the captured text was wrong in version 1.1.0. Oops. As of version 1.1.1 the following GNU extensions are recognized, all anchors: \` at beginning of entire text \' at end of

[Haskell-cafe] Re: doubts about runGetState in the binary package

2009-03-19 Thread ChrisK
Manlio Perillo wrote: Hi. I have some doubts about the runGetState function in the binary package. The signature is: runGetState :: Get a - LBS - Int64 - (a, LBS, Int64) however the Int64 input parameter is not documented. What value should I pass? How will be used? Thanks Manlio Perillo

[Haskell-cafe] ANN: regex-tdfa-1.1.0

2009-03-18 Thread ChrisK
I have just uploaded the new regex-tdfa-1.1.0 to hackage. This version is a small performance update to the old regex-tdfa-1.0.0 version. Previously all text (e.g. ByteString) being search was converted to String and sent through a single engine. The new version uses a type class and

[Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen?

2009-03-16 Thread ChrisK
Thomas Hartman wrote: testPcre = ( subRegex (mkRegex (?!\n)\n(?!\n)) asdf\n \n\n\nadsf ) == asdf \n\n\nadsf quoting from the man page for regcomp: REG_NEWLINE Compile for newline-sensitive matching. By default, newline is a completely ordinary character with no special

[Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen?

2009-03-16 Thread ChrisK
Thomas Hartman wrote: testPcre = ( subRegex (mkRegex (?!\n)\n(?!\n)) asdf\n \n\n\nadsf ) == asdf \n\n\nadsf quoting from the man page for regcomp: REG_NEWLINE Compile for newline-sensitive matching. By default, newline is a completely ordinary character with no special

[Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen?

2009-03-16 Thread ChrisK
Don Stewart wrote: tphyahoo: Is there something like subRegex... something like =~ s/.../.../ in perl... for haskell pcre Regexen? I mean, subRegex from Text.Regex of course: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-compat Thanks for any advice, Basically, we should

[Haskell-cafe] Re: Alternative to Data.Binary

2009-03-14 Thread ChrisK
Grzegorz Chrupala wrote: Hi all, Is there a serialization library other than the Data.Binary from hackage? Yes. binary-strict is one alternative: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-strict I am using Data.Binary in a couple of projects, but I have found

[Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen?

2009-03-12 Thread ChrisK
Thomas Hartman wrote: Is there something like subRegex... something like =~ s/.../.../ in perl... for haskell pcre Regexen? I mean, subRegex from Text.Regex of course: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-compat Thanks for any advice, thomas. Short answer: No.

[Haskell-cafe] Re: do nmergeIO or mergeIO preserve order?

2009-03-11 Thread ChrisK
Anatoly Yakovenko wrote: do nmergeIO or mergeIO preserve order? or not preserve order? If you have a list of operations [IO a] then the future package at http://hackage.haskell.org/cgi-bin/hackage-scripts/package/future can do this. It's 'forkPromises' function returns a Chan a which can be

[Haskell-cafe] Re: ANN: Future 1.1.0 concurrency library

2009-03-10 Thread ChrisK
Don Stewart wrote: Who needs to build futures into the language -- all you need is MVars, eh? For a pure computation in Haskell one can use par (which did take changing the runtime, and arguably adding to the language). The future package I uploaded is just a clean way to get something a

[Haskell-cafe] ANN: Future 1.1.0 concurrency library

2009-03-09 Thread ChrisK
Hello, As a side effect of the discussion of the new C++ future/promise features at http://lambda-the-ultimate.org/node/3221 I have implemented a Haskell package called future at http://hackage.haskell.org/cgi-bin/hackage-scripts/package/future This ought to do what C++ standard

[Haskell-cafe] Re: Data.Binary stack overflow with Data.Sequence String

2009-03-04 Thread ChrisK
I have collected some of the backing code to decode. This is all pasted below so we can look at it. I will not improperly guess at the cause of the problem, and be totally wrong. I observe Get is a lazy monad: Prelude Data.Binary Data.Binary.Get Data.Monoid World == runGet ((return $!

[Haskell-cafe] major speed improvement: regex-tdfa reaches 1.0.0

2009-03-01 Thread ChrisK
for wcs on 2^8 and 2^9 and 2^10 are: Reason:compare-tdfa chrisk$ time ./Test-TDFA-np wcs3 8 +RTS -sstderr 21 | head -4 ./Test-TDFA-np wcs3 8 +RTS -sstderr Test for [Char] Right [array (0,1) [(0,(257,1)),(1,(-1,0))]] 263,776,756 bytes allocated in the heap user0m1.017s sys 0m0.058s

[Haskell-cafe] ANN: bug fix for regex-tdfa, version 0.97.4 (and regex-ast)

2009-02-24 Thread ChrisK
Hello, The regex-tdfa package has had a series of bug fix releases (0.97.1 and 2 and 3 and now 4). This 0.97.4 releases finishes fixing the bug that was only mostly fixed in the 0.97.1 release. An example of the fixed bug: Apply the regex pattern (BB(B?))+(B?) to the text . The BB

[Haskell-cafe] Re: speed: ghc vs gcc

2009-02-20 Thread ChrisK
On a G4: s.hs (which does not need bang patterns) is: main = seq (sum0 (10^9) 0) (return ()) sum0 :: Int - Int - Int sum0 0 acc = acc sum0 x acc = sum0 (x-1) $! (acc+x) And s.c is (actually including 10^9, which Bulat's did not): main() { int sum=0; for(int i=1000*1000*1000; i0; i--)

[Haskell-cafe] ANN: Bug fix to regex-tdfa, new version 0.97.3

2009-02-10 Thread ChrisK
To Haskell and Libraries and Haskell-Cafe, Whilst improving regex-tdfa I have run across new bugs. Some patterns were getting compiled wrong and others were affected by an execution bug. As this package has actual users, I wanted to make sure they get these fixes immediately. Three Cheers

[Haskell-cafe] Re: Fastest regex package?

2009-02-05 Thread ChrisK
Eugene Kirpichov wrote: All in all, my question remains: what is the fastest way to do this kind of parsing on a lazy bytestring? Your example regular expression works the same in both Posix and Perl-ish semantics. Do you know the difference? Posix libraries look for the longest match of

[Haskell-cafe] Re: evaluation semantics of bind

2009-02-05 Thread ChrisK
Gregg Reynolds wrote: getChar = \x - getChar An optimizer can see that the result of the first getChar is discarded True, so 'x' is not used, and it can be garbage collected, and may not even be created. But that data dependency is simple not the data dependency that make IO

[Haskell-cafe] Re: Monad explanation

2009-02-05 Thread ChrisK
All Haskell programs start as main :: IO () though... so they all get evaluated in the context of another IO () don't they? True for most cases now, but historically false. Haskell existed and people wrote programs for years before the Monad class and IO were created. A Haskell98

[Haskell-cafe] Re: evaluation semantics of bind

2009-02-05 Thread ChrisK
Jonathan Cast wrote: On Fri, 2009-02-06 at 00:51 +0100, Peter Verswyvelen wrote: On Thu, Feb 5, 2009 at 8:20 PM, ChrisK hask...@list.mightyreason.com wrote: Since this is strict there is no laziness and the code must evaluate the input and output State RealWorld to ensure

[Haskell-cafe] ANN: regex-posix-unittest-1.0 AND regex-posix-0.94.1 AND regex-tdfa-0.97.1

2009-02-02 Thread ChrisK
I have three announcements to make about regex-* related packages. The regex-posix-0.94.1 package update provides better semantics for multiple matches. Below version 0.94, if any match was empty the matching would stop. Now the empty match is returned and the position is incremented and the

[Haskell-cafe] Re: ANN: HTTPbis / HTTP-4000.x package available

2009-01-21 Thread ChrisK
Duncan Coutts wrote: Proxy auto-configuration files are JavaScript. It uses more or less the full JavaScript language (ECMA these days), though with a small subset of the standard library. W T F So we want a tiny naive javascript interpreter, hopefully in pure Haskell. The dumbest

[Haskell-cafe] Re: Existencial quantification and polymorphic datatypes

2009-01-20 Thread ChrisK
Mauricio wrote: Hi, I'm trying, without success, to understand the difference between existencial quantification and polymorphic datatypes. Can you give me a hint, or an example where one is valid and the other is not? The first thing to ensure you know is that Haskell can have functions

[Haskell-cafe] Re: Existencial quantification and polymorphic datatypes (actually, components...)

2009-01-20 Thread ChrisK
Great, thanks! I'm enlightened :) And no one had to hit you with a stick first! But how is this: data SomeNum = forall a. SN a different from: data SomeNum = SN (forall a. a) ? At a glance they look the same to me — but only the first is accepted by ghc. There is also the GADT syntax:

[Haskell-cafe] Re: Bug in Text.Regex.PCRE - do not accept national symbol in pattern

2009-01-19 Thread ChrisK
Alexandr, Thanks for sending me this question about unicode and regex-pcre. I will share with the mailing list. This is an encoding issue. From the haddock documentation for regex-pcre: http://hackage.haskell.org/packages/archive/regex-pcre/0.94.1/doc/html/Text-Regex-PCRE.html Using the

[Haskell-cafe] Re: How to make code least strict?

2009-01-19 Thread ChrisK
Robin Green wrote: What guidelines should one follow to make Haskell code least-strict? Obviously the use of seq and bang-patterns make code more strict. Code is strict when it evaluates values to determine a pattern match. So avoiding that makes code lazier. Values are evaluated when

[Haskell-cafe] Re: some ideas for Haskell', from Python

2009-01-19 Thread ChrisK
Manlio Perillo wrote: Brandon S. Allbery KF8NH ha scritto: ...in theory. In practice GHC needs help with circular imports, and some cycles might be impossible to resolve. This is interesting. Where can I find some examples? Is this explained in the Real World Haskell book? I have no

[Haskell-cafe] Re: Comments from OCaml Hacker Brian Hurt

2009-01-16 Thread ChrisK
Dan Weston wrote: Richard Feinman once said: if someone says he understands quantum mechanics, he doesn't understand quantum mechanics. But what did he know... Well, I am a physicist and Feynman (with a y, not an i), is not talking about the linear algebra. Of course, linear algebra [1]

[Haskell-cafe] Re: Comments from OCaml Hacker Brian Hurt

2009-01-16 Thread ChrisK
Here is a great Monoid found in the wild story: I just implemented a library for binary message serialization that follows Google's protocol buffer format. The documentation of this was very scattered in some respects but I kept reading snippets which I have pasted below. The effect of

[Haskell-cafe] Re: Compiling regex-posix-0.93.2 on windows

2009-01-15 Thread ChrisK
Paulo: I suggest doing this more carefully. Get the source from hackage. Edit the regex-posix.cabal file to add the include and lib directories you need on Cygwin. cabal configure it. cabal build it. cabal install it. Then in an unrelated directory try and run ghci -package regex-posix.

[Haskell-cafe] Re: Comments from OCaml Hacker Brian Hurt

2009-01-15 Thread ChrisK
Thomas DuBuisson wrote: How does forcing them to learn proposed terminology such as `Appendable' help here? Learners of Haskell do still need to learn what the new word means. The contention is that 'Appendable' is an intuitive naming that people will already have a rudimentary grasp of.

[Haskell-cafe] Re: Monads aren't evil? I think they are.

2009-01-13 Thread ChrisK
Henning Thielemann wrote: I have seen several libraries where all functions of a monad have the monadic result (), e.g. Binary.Put and other writing functions. This is a clear indicator, that the Monad instance is artificial and was only chosen because of the 'do' notation. I completely

Re: [Haskell-cafe] Re: System.CPUTime and picoseconds

2009-01-12 Thread ChrisK
Neil Davies wrote: I've found the pico second accuracy useful in working with 'rate equivalent' real time systems. Systems where the individual timings (their jitter) is not critical but the long term rate should be accurate - the extra precision helps with keeping the error accumulation under

[Haskell-cafe] Re: [Haskell] ANN: ghci-haskeline 0.1

2009-01-12 Thread ChrisK
Haskeline is designed to remove the readline dependency, because Windows does not have readline. So rlwrap is useless there. Andrew Hunter wrote: On Mon, Jan 12, 2009 at 12:57:57PM -0800, Judah Jacobson wrote: I'm pleased to announce the first release of ghci-haskeline. This package uses

[Haskell-cafe] Re: System.CPUTime and picoseconds

2009-01-12 Thread ChrisK
Tony Finch wrote: The FreeBSD kernel uses a 64+64 bit fixed point type to represent time, where the integer part is a normal Unix time_t. The fractional part is 64 bits wide in order to be able to represent multi-GHz frequencies precisely. multi-GHz being a euphemism for 18.45*10^9 GHz, over

[Haskell-cafe] Re: System.CPUTime and picoseconds

2009-01-11 Thread ChrisK
An Double or Int64 are both 8 bytes and counts with picoseconds precision for 2.5 hours to 106 days. Going to 12 byte integer lets you count to 3.9 billion years (signed). Going to 16 byte integer is over 10^38 years. Lennart Augustsson wrote: A double has 53 bits in the mantissa which

[Haskell-cafe] Re: Computer time, independent of date

2009-01-10 Thread ChrisK
Mauricio wrote: patients, I wanted to be sure not to save wrong information. It wouldn't matter if the clock is saying we are on XVII century, as long as 10 seconds would never be 10.1. Chris (yes I am an experimental physicist) asks: What are the interval durations you need to measure?

[Haskell-cafe] Re: System.CPUTime and picoseconds

2009-01-10 Thread ChrisK
Manlio Perillo wrote: Hi. Just out of curiosity, but why Haskell 98 System.CPUTime library module uses picoseconds instead of, say, nanoseconds? At least on POSIX systems, picoseconds precision is *never* specified. I have not idea. But at a guess, I would say that 1 ns is not such a

[Haskell-cafe] Re: Haskell not ready for Foo [was: Re: Hypothetical Haskell job in New York]

2009-01-08 Thread ChrisK
John A. De Goes wrote: Here's hoping someone develops a native messaging framework for Haskell, which is the equal of RabbitMQ. The first thing would be to make a Haskell client library to speak AMQP (Advanced Message Queuing Protocol) on the wire. It is a very open binary standard

[Haskell-cafe] Re: Tying a simple circularly STM linked list

2009-01-06 Thread ChrisK
You can use undefined or error ... : {-# LANGUAGE RecursiveDo #-} import Control.Concurrent.STM import Control.Monad.Fix -- Transactional loop. A loop is a circular link list. data Loop a = ItemLink { item :: a , prev :: TVar (Loop a) , next :: TVar (Loop a) } --

[Haskell-cafe] Re: ANN: bytestring-trie 0.1.1 (bugfix)

2009-01-04 Thread ChrisK
Question and suggestion: looking at http://hackage.haskell.org/packages/archive/bytestring-trie/0.1.1/doc/html/src/Data-Trie.html#Trie I am questioning your choice of foldr in fromList: -- | Convert association list into a trie. On key conflict, values -- earlier in the list shadow later

[Haskell-cafe] Different QSem(N) (was Re: IORef vs TVar performance: 6 seconds versus 4 minutes)

2008-12-29 Thread ChrisK
I think I can improve on your code. Bertram Felgenhauer wrote: But why does it manually manage the waiters at all? MVars are fair, in ghc at least. So this should work: data Sem = Sem (MVar Int) (MVar Int) I changed the above to be a data newSem :: Int - IO Sem newSem

[Haskell-cafe] Re: Using classes for a heterogeneous graph structure

2008-12-29 Thread ChrisK
I think the below code which compiles with ghc-6.10.1 should compile with ghc-6.8.3 as well. My preference is to define a GADT such as ThingMap below. Conceptually ThingMap contains two pieces of information. There is a Map to an unknown type thing and there is a dictionary which implements

[Haskell-cafe] Re: Infinite grid

2008-12-29 Thread ChrisK
Luke Palmer wrote: On Mon, Dec 29, 2008 at 3:55 PM, Martijn van Steenbergen mart...@van.steenbergen.nl mailto:mart...@van.steenbergen.nl wrote: Hello, I would like to construct an infinite two-dimensional grid of nodes, where a node looks like this: data Node = Node

[Haskell-cafe] Re: Missing Network Functions

2008-12-28 Thread ChrisK
John Van Enk wrote: I want to group them with Network functions because traditionally these specific functions *are* in networking packages. I agree. It is true that these functions are in the arpa/inet.h header on my machine. The ntoh* and hton* are just data manipulation, just as

[Haskell-cafe] Re: How does one use Text.Regex.Base.RegexLike?

2008-12-25 Thread ChrisK
Yeah! I am glad the mailing list has helped. If you get stuck or need something fancier then let me know (I wrote RegexLike). But I still don't know how to get makeRegex to work. You need it to specify options like case insensitivity, or to use functions like matchAllText. Well, the

[Haskell-cafe] Re: What are side effects in Haskell?

2008-12-23 Thread ChrisK
Hans van Thiel wrote: I just saw somewhere that one of the purposes of monads is to capture side effects. There are a few things that have side effects. The best way to capture this is to see that there are both (1) commands whose result depends on some external state (2) commands which

[Haskell-cafe] Re: How to think about this? (profiling)

2008-12-16 Thread ChrisK
Or if you don't want to pay for laziness at all you could build your memo array imperatively (but purely): import Data.Array.IArray(elems,(!),inRange) import Data.Array.MArray(newArray_,writeArray,readArray) import Data.Array.Unboxed(UArray) import Data.Array.ST(runSTUArray,STUArray) import

[Haskell-cafe] Re: Type wildcards

2008-12-16 Thread ChrisK
You can get pretty far with the same trick oleg mentions at [1]. If you use local type signature then you can do things like this: {- ghci infers this type: *Main :t f f :: (Ord a) = Int - a - t - String -} f i j x | False = (undefined (i::Int) (isOrd j)) :: String f i j x = error not filled

[Haskell-cafe] Re: MVar and Par ..

2008-12-16 Thread ChrisK
Mozhgan Kabiri wrote: Hi .. Hope you are doing well . I've just joined this group. Hi. Recently, I am struggling to do some simple experiment with haskell language about parallelism and wrong answers that we can get while using a shared variable . Your goal is still unclear. Are you

[Haskell-cafe] Re: File name encodings

2008-12-10 Thread ChrisK
Duncan Coutts wrote: Yet another reason why FilePath /= String (except on Windows where it does). Duncan Well, it is not a OS issue but a FileSystem issue. OS X is a Unix, but the main filesystem is HFS+ which has Unicode names, though they use a different normalization. So FilePath ==

[Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4

2008-12-10 Thread ChrisK
Is there anyway to track down and fix why haskell-src-exts-0.4.4.1 still gets haddock: parse error in doc string when I try to get cabal to haddock the package? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4

2008-12-10 Thread ChrisK
Ross Paterson wrote: On Wed, Dec 10, 2008 at 05:34:16PM +, ChrisK wrote: Is there anyway to track down and fix why haskell-src-exts-0.4.4.1 still gets haddock: parse error in doc string when I try to get cabal to haddock the package? Line numbers would be handy. In this case

[Haskell-cafe] Re: ANNOUNCE: haskell-src-exts 0.4.4

2008-12-04 Thread ChrisK
Niklas Broberg wrote: Fellow Haskelleers, it is my pleasure to announce the new release of the haskell-src-exts package, version 0.4.4: The full list of pragmas supported by 0.4.4 is: SOURCE, RULES, DEPRECATED, WARNING, INLINE, NOINLINE, SPECIALISE, CORE, SCC, GENERATED and UNPACK. Ah,

[Haskell-cafe] Re: The Knight's Tour: solutions please

2008-12-02 Thread ChrisK
Hmmm... it seems that n=63 is a special case. [EMAIL PROTECTED] wrote: Yes, there is a solution for n=99 and for n=100 for that matter -- which can be found under one second. I only had to make a trivial modification to the previously posted code tour n k s b | k n*n = return b

[Haskell-cafe] Re: Question about fastcgi

2008-11-28 Thread ChrisK
Er, no. A fastcgi executable is (like a cgi executable) controlled by the front end web server. I run my fastcgi using Apache as the front end. The front end web server will control things like the port number. Mauricio wrote: Hi, I'm learnng to use fastcgi and, reading the examples, I

[Haskell-cafe] Re: Question about fastcgi

2008-11-28 Thread ChrisK
I have only used this, all of these are from Haskell: pamac-cek10:~ chrisk$ cat /etc/apache2/other/httpd-fastcgi.conf IfModule mod_fastcgi.c Alias /fcgi-bin/ /Library/WebServer/FastCGI-Executables/ Directory /Library/WebServer/FastCGI-Executables/ AllowOverride None Options None

[Haskell-cafe] Re: Efficient parallel regular expressions

2008-11-04 Thread ChrisK
The regex-tdfa package (and regex-posix) implement subexpressions capture. So if you want to match alpha beta and gamma in parallel you could write (alpha)|(beta)|(gamma) and check which subexpression has the non-empty match. This becomes slightly complicated if there are parenthesis and

[Haskell-cafe] Re: Climbing up the shootout...

2008-09-22 Thread ChrisK
And, though I had never seen it before, the current winner for speed is ATS ( http://www.ats-lang.org/ ) which is dependently-typed functional language. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] ANNOUNCE: protocol-buffers-0.2.9 for Haskell is ready

2008-09-20 Thread ChrisK
Hello one and all, Amid much rejoicing, my Haskell version of protocol-buffer is now released (version 0.2.9). What is this for? What does it do? Why? Shorter answer: It generates Haskell data types that can be converted back and forth to lazy ByteStrings that interoperate with Google's

[Haskell-cafe] Re: STM and FFI

2008-09-10 Thread ChrisK
There are some examples of adding IO actions to commit and rollback events at http://www.haskell.org/haskellwiki/New_monads/MonadAdvSTM Disclaimer: I wrote this instance of the code, but have not used it much. Cheers, Chris ___ Haskell-Cafe

[Haskell-cafe] Re: [Haskell] The initial view on typed sprintf and sscanf

2008-09-02 Thread ChrisK
Matthew Brecknell wrote: Unfortunately, I don't seem to be able to make the expected fprintf function, because printf's format-dependent parameter list makes it impossible to find a place to pass the handle. Hence the C++-like () ugliness. How about this: fprintf :: Handle - F (IO ()) b -

[Haskell-cafe] Re: Brainstorming on how to parse IMAP

2008-08-05 Thread ChrisK
Hi John, I recently posted new and fancy binary Get monads in http://article.gmane.org/gmane.comp.lang.haskell.libraries/9691 and http://article.gmane.org/gmane.comp.lang.haskell.libraries/9756 which might be of interest since network protocol are usually specified in bytes at the wire level.

[Haskell-cafe] Re: Brainstorming on how to parse IMAP

2008-08-05 Thread ChrisK
I am glad you asked Ben, Short answer: It can return a Seq of your values. The values in the Seq are lazy, the Seq itself is finite. It can return what it has so far before it finishes parsing (or even before the rest of the input has arrived from the network). Ben Franksen wrote: ChrisK

[Haskell-cafe] Re: ANN: haskell-src-exts 0.3.5

2008-07-15 Thread ChrisK
Thanks for the fix. I have gotten the darcs version and I am compiling... Niklas Broberg wrote: Hi all, I'm pleased to report that haskell-src-exts is now updated to understand Template Haskell syntax (it used to understand pre-6.4 TH, but now it works with the current version). At least I

[Haskell-cafe] Template Haskell and haskell-src-exts

2008-07-10 Thread ChrisK
Hi, Can one represent the ''Type template Haskell syntax of $( makeMergeable ''FileDescriptorProto ) in haskell-src.exts Language.Haskell.Exts.Syntax ? And what are the HsReify data (e.g. HsReifyType and HsReifyDecl and HsReifyFixity )? I don't see any pretty print capability to produce

[Haskell-cafe] Re: A Monad for on-demand file generation?

2008-07-03 Thread ChrisK
Joachim Breitner wrote: * The 5th line does not have this effect. Because this gets desugared to (), the special implementation of () means that the next line still sees the same dependency state as the before the call to liftIO. You are violating the monad laws. (f k) and (f = \_ - k)

[Haskell-cafe] Re: A Monad for on-demand file generation?

2008-07-02 Thread ChrisK
hen, the readFileOD could put the timestamp of the read file in a Monad-local state and the writeFileOD could, if the output is newer then all inputs listed in the state, skip the writing and thus the unsafeInterleaveIO’ed file reads are skipped as well, if they were not required for deciding the

[Haskell-cafe] Re: Writing an 'expect'-like program with runInteractiveCommand

2008-05-01 Thread ChrisK
Are you adjusting 'System.IO.hSetBuffering' to NoBuffering for those handles? Graham Fawcett wrote: Hi folks, I would like to communicate with an external, line-oriented process, which takes a sequence of one-line commands, each returning an arbitrary number of lines, and waits for another

[Haskell-cafe] Re: Caching the Result of a Transaction?

2008-04-28 Thread ChrisK
The garbage collector never gets to collect either the action used to populate the cached value, or the private TMVar used to hold the cached value. A better type for TIVal is given below. It is a newtype of a TVal. The contents are either a delayed computation or the previously forced

[Haskell-cafe] Re: Wrong Answer Computing Graph Dominators

2008-04-18 Thread ChrisK
More algebraically, including 'or' for symmtry: and xs = foldr () True xs or xs = foldr (||) False xs The True and False are the (monoid) identities with respect to and || : True x == x x True == x False || x == x x || False == x And so an empty list, if defined at all, should be the

[Haskell-cafe] Re: semi-closed handles

2008-04-15 Thread ChrisK
Ryan Ingram wrote: I usually use something like this instead: hStrictGetContents :: Handle - IO String hStrictGetContents h = do s - hGetContents h length s `seq` hClose h return s A small idiomatic nitpick: When I see (length s) gets computed and thrown away I wince at the

[Haskell-cafe] Re: Type families and GADTs in 6.9

2008-04-12 Thread ChrisK
The length calculation looked complicated. So I reformulated it as a comparison using HasIndex. But ghc-6.8.2 was not inferring the recursive constraint on proj, so I split proj into proj_unsafe without the constraint and proj with the constraint checked only once. I also renamed ZT to Nil

[Haskell-cafe] Re: Longest increasing subsequence

2008-04-11 Thread ChrisK
It is late, but I was not sleepy enough, so here is my first translation of the algorithm to a functional approach... {- Quote wikipedia: http://en.wikipedia.org/wiki/Longest_increasing_subsequence L = 0 M[0] = 0 for i = 1, 2, ... n: binary search for the largest j ≤ L such that

[Haskell-cafe] Re: Longest increasing subsequence

2008-04-11 Thread ChrisK
My late night suggestions were nearly correct. I have actually written the code now. Once keeping track of indices, and a second time without them: {-# LANGUAGE BangPatterns #-} -- By Chris Kuklewicz, copyright 2008, BSD3 license -- Longest increasing subsequence -- (see

[Haskell-cafe] Re: Dynamic typing makes you more productive?

2008-03-18 Thread ChrisK
Jules Bean wrote: Justin Bailey wrote: From a recent interview[1] with the guy leading Ruby development on .NET at Microsoft: You spend less time writing software than you spend maintaining software. Optimizing for writing software versus maintaining software is probably the wrong thing

[Haskell-cafe] Re: Small displeasure with associated type synonyms

2008-03-06 Thread ChrisK
Tom Schrijvers wrote: Stefan, I tried lexically scoped type variables, but to no avail: instance forall a b. (C a, C b) = C (a, b) where type T (a, b) = (T a, T b) val = (val :: T a, val :: T b) The problem is ambiguity. The type checker can't determine which val function to

[Haskell-cafe] Re: Small displeasure with associated type synonyms

2008-03-06 Thread ChrisK
Okay, I get the difference. The T a annotation in val :: T a)and val :: T a does not help choose the C a dictionary. But the val :: a- T a and val (undefined :: a) allows a to successfully choose the C a dictionary. val :: T a fixes T a but does not imply C a. (undefined :: a) fixes a and

[Haskell-cafe] Re: Create a list without duplicates from a list with duplicates

2008-02-09 Thread ChrisK
For Bimap is there anything like Data.Map.insertWithKey ? Stuart Cook wrote: On Sat, Feb 9, 2008 at 7:36 AM, Dan Weston [EMAIL PROTECTED] wrote: If order is important, the new bijective Data.Bimap class http://code.haskell.org/~scook0/haddock/bimap/Data-Bimap.html may be your best bet (I

[Haskell-cafe] Re: weird ghci behavior with gadts and existentials

2008-02-06 Thread ChrisK
Let me add: data ExpGADT t where ExpInt :: Int - ExpGADT Int ExpChar :: Char - ExpGADT Char Which type do you think 'unHide' and 'wierd' should have: unHide h = case h of Hidden (_,e) - e wierd = unHide (Hidden (TyInt,ExpInt 3)) either: unHide :: HiddenTypeExp -

[Haskell-cafe] Re: A handy little consequence of the Cont monad

2008-02-01 Thread ChrisK
The bit of a mess that comes from avoiding monads is (my version): import Foreign.Marshal.Array(withArray0) import Foreign.Ptr(nullPtr,Ptr) import Foreign.C.String(withCString,CString) This uses withCString in order of the supplied strings, and a difference list ([CString]-[CString])

[Haskell-cafe] Security Notice: Buffer overflow fixed in PCRE library

2008-01-30 Thread ChrisK
The PCRE library has just fixed a buffer overflow (related to UTF-8 mode). There are several haskell wrappers for the pcre library. If you use a wrapper for the PCRE library (libpcre) then you may want to upgrade the underlying library. http://pcre.org/news.txt states: News about PCRE

[Haskell-cafe] Re: Why functional programming matters

2008-01-25 Thread ChrisK
Simon Peyton-Jones wrote: 1. Small examples of actual code. I particularly like the lazy way of counting change example (also works for picking items off a menu). The code below show 3 approaches : a function for computing the coins used in each way as a verbose list a function for

[Haskell-cafe] Re: Why functional programming matters

2008-01-24 Thread ChrisK
Achim Schneider wrote: Don Stewart [EMAIL PROTECTED] wrote: jwlato: In addition to STM, another item that should interest serious programmers is forkIO. Lightweight threads that (unlike in Python) can use multiple cpu's. Coming from Python, I personally appreciate this. Using STM to handle

[Haskell-cafe] Re: \_ - not equivalent to const $

2008-01-15 Thread ChrisK
Luke Palmer wrote: In attempting to devise a variant of cycle which did not keep its argument alive (for the purpose of cycle [1::Int..]), I came across this peculiar behavior: import Debug.Trace cycle' :: (a - [b]) - [b] cycle' xs = xs undefined ++ cycle' xs take 20 $ cycle' (const $

[Haskell-cafe] Re: Haskell and GUI

2008-01-15 Thread ChrisK
The advice below is for Mac OS X 10.4 and below. Starting with Mac OS X 10.5 (Leopard) the DISPLAY is set for you by the operating system. Mine is currently /tmp/launch-sQZXQV/:0 which looks very strange because it is used to cause the launchd daemon to start the X server on demand (i.e.

[Haskell-cafe] Re: Implicit parameters and Arrows/Yampa?

2008-01-07 Thread ChrisK
Could I has one question? What is the purpose of the stream function in the ArrowLoop instance? Is it just to catch an unexpected [] at runtime? 8 module Main where import Control.Arrow import Control.Arrow.Operations import Control.Arrow.Transformer.Reader -- -- Standard

[Haskell-cafe] ANN: Build fixed for regex-base,posix,compat,pcre

2008-01-07 Thread ChrisK
ANNOUNCEMENT: Build fixed for regex-base, regex-posix, regex-compat, regex-pcre The changes are mainly to the Cabal build files to support ghc-6.8 and ghc-6.6 simultaneously. They definitely work with cabal version 1.2.3.0 (required for regex-pcre). The regex-base, regex-posix, and

[Haskell-cafe] Re: Quanta. Was: Wikipedia on first-class object

2008-01-06 Thread ChrisK
Brandon S. Allbery KF8NH wrote: On Jan 6, 2008, at 15:02 , Ketil Malde wrote: More seriously, perhaps quantum enters into the equation in how the brain works, perhaps it is even necessary for thought. However, I get worried it's just another mystical mantra, a gratuitous factor that, lacking

[Haskell-cafe] Re: Missing join and split

2007-12-29 Thread ChrisK
Mitar wrote: Hi! On Dec 28, 2007 5:51 PM, Lihn, Steve [EMAIL PROTECTED] wrote: Since regex is involved, it is specific to (Byte)String, not a generic list. Oh, this gives me an interesting idea: making regular expressions more generic. The new regex-base API is fairly generic. If you

[Haskell-cafe] Re: Missing join and split

2007-12-29 Thread ChrisK
Albert Y. C. Lai wrote: Mitar wrote: I am really missing the (general) split function built in standard Haskell. I do not understand why there is something so specific as words and lines but not a simple split? The same goes for join. Don't forget Text.Regex.splitRegex. Which is just:

[Haskell-cafe] Re: what does @ mean?.....

2007-12-28 Thread ChrisK
Nicholls, Mark wrote: Hello, I wonder if someone could answer the following… The short question is what does @ mean in mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' x@(S a) y orig | x == one = y

[Haskell-cafe] Re: Wikipedia on first-class object

2007-12-28 Thread ChrisK
This thread is obviously a source of much fun. I will play too. Cristian Baboi wrote: On Fri, 28 Dec 2007 18:32:05 +0200, Jules Bean [EMAIL PROTECTED] wrote: Cristian Baboi wrote: Let me ask you 3 simple questions. Can one use Haskell to make dynamically linked libraries (DLL on Windows,

[Haskell-cafe] Re: Missing join and split

2007-12-28 Thread ChrisK
Lihn, Steve wrote: Programmer with perl background would think split like: list of string = split regex original string Since regex is involved, it is specific to (Byte)String, not a generic list. Also it appears one would need help from Text.Regex(.PCRE) to do that. intercalate a

[Haskell-cafe] Re: Doing some things right

2007-12-28 Thread ChrisK
Brian Sniffen wrote: On Dec 28, 2007 6:05 AM, Andrew Coppin [EMAIL PROTECTED] wrote: [I actually heard a number of people tell me that learning LISP would change my life forever because LISP has something called macros. I tried to learn it, and disliked it greatly. It's too messy. And what the

  1   2   >