Re: [Haskell-cafe] [iteratee] how to do nothing .. properly

2011-06-02 Thread John Lato
Hi Sergey,

I can't explain this; maybe it's a bug in enumWith?  I'll look into it.

Thanks,
John


 Message: 20

Date: Thu, 2 Jun 2011 02:46:32 +0400
 From: Sergey Mironov ier...@gmail.com
 Subject: [Haskell-cafe] [iteratee] how to do nothing .. properly
 To: haskell-cafe@haskell.org
 Message-ID: BANLkTimMFRWgH9Nopt-eua+L7jQcGq+u=g...@mail.gmail.com
 Content-Type: text/plain; charset=ISO-8859-1

 Hi. Would anybody explain a situation with iter6 and iter7 below?
 Strange thing - first one consumes no intput, while second consumes it
 all, while all the difference is peek  which should do no processing
 (just copy next item in stream and return to user).
 What I am trying to do - is to write an iteratee consuing no input,
 but returning a constant I give to it. I thought (return a) should do
 it, but it seems I was wrong as return actually consumes all unparsed
 stream. iter6 experience tells me that (peekreturn a) is what I
 need, but it's completely confusing and not what I expected.

 Thanks,
 Sergey

  import Data.Iteratee as I
  import Data.Iteratee.IO
  import Control.Monad
  import Control.Exception
  import Data.ByteString
  import Data.Char
  import Data.String

  -- countBytes :: (..., Num b) = Iteratee s m a - Iteratee s m (a, b)
  countBytes i = enumWith i I.length

  iter6 = do
 h - countBytes $ (peek  return 0)
 s - I.stream2list
 return (h,s)

  iter7 = do
 h - countBytes $ (return 0)
 s - I.stream2list
 return (h,s)

  print6 = enumPure1Chunk [1..10] (iter6) = run = print
  print7 = enumPure1Chunk [1..10] (iter7) = run = print


 Here is example ghci session

 *Main print6
 ((0,0),[1,2,3,4,5,6,7,8,9,10])
 -- read 0 items, returns 0
 *Main print7
 ((0,10),[])
 -- read 10 items (???) returns 0
 *Main



 --

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


 End of Haskell-Cafe Digest, Vol 94, Issue 3
 ***

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [iteratee] how to do nothing .. properly

2011-06-02 Thread Sergey Mironov
Ok. I've checked iteratee-0.8.3.0 and 0.8.4.0. Results are same.

Sergey

2011/6/2 John Lato jwl...@gmail.com:
 Hi Sergey,
 I can't explain this; maybe it's a bug in enumWith?  I'll look into it.
 Thanks,
 John


 Message: 20

 Date: Thu, 2 Jun 2011 02:46:32 +0400
 From: Sergey Mironov ier...@gmail.com
 Subject: [Haskell-cafe] [iteratee] how to do nothing .. properly
 To: haskell-cafe@haskell.org
 Message-ID: BANLkTimMFRWgH9Nopt-eua+L7jQcGq+u=g...@mail.gmail.com
 Content-Type: text/plain; charset=ISO-8859-1

 Hi. Would anybody explain a situation with iter6 and iter7 below?
 Strange thing - first one consumes no intput, while second consumes it
 all, while all the difference is peek  which should do no processing
 (just copy next item in stream and return to user).
 What I am trying to do - is to write an iteratee consuing no input,
 but returning a constant I give to it. I thought (return a) should do
 it, but it seems I was wrong as return actually consumes all unparsed
 stream. iter6 experience tells me that (peekreturn a) is what I
 need, but it's completely confusing and not what I expected.

 Thanks,
 Sergey

  import Data.Iteratee as I
  import Data.Iteratee.IO
  import Control.Monad
  import Control.Exception
  import Data.ByteString
  import Data.Char
  import Data.String

  -- countBytes :: (..., Num b) = Iteratee s m a - Iteratee s m (a, b)
  countBytes i = enumWith i I.length

  iter6 = do
     h - countBytes $ (peek  return 0)
     s - I.stream2list
     return (h,s)

  iter7 = do
     h - countBytes $ (return 0)
     s - I.stream2list
     return (h,s)

  print6 = enumPure1Chunk [1..10] (iter6) = run = print
  print7 = enumPure1Chunk [1..10] (iter7) = run = print


 Here is example ghci session

 *Main print6
 ((0,0),[1,2,3,4,5,6,7,8,9,10])
 -- read 0 items, returns 0
 *Main print7
 ((0,10),[])
 -- read 10 items (???) returns 0
 *Main



 --

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


 End of Haskell-Cafe Digest, Vol 94, Issue 3
 ***



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How on Earth Do You Reason about Space?

2011-06-02 Thread Ketil Malde

Since frequency counts are an important use of map-like data structures,
I did a brief test of the available options.  First using regular
strings for input, and Data.Map.fromListWith - i.e. the operational bit being:

  freqs :: [String] - M.Map String Int
  freqs = M.fromListWith (+) . map (,1)

This runs on a 14M corpus consisting of King James Bible, collected
works of Shakespeare, and War and Peace.

./freqstr1 +RTS -s 
   5,093,386,368 bytes allocated in the heap
   2,682,667,904 bytes copied during GC
 261,110,368 bytes maximum residency (20 sample(s))
   9,018,000 bytes maximum slop
 623 MB total memory in use (10 MB lost due to fragmentation)
./freqstr1 +RTS -s  21.43s user 0.78s system 99% cpu 22.285 total

Kinda expensive, 250MB to store word frequencies of 14MB text.

Now, changing to 

  freqs :: [String] - M.Map String Int
  freqs = foldl' (\m w - M.insertWith' (+) w 1 m) M.empty

i.e. using strict insertion, avoiding the buildup of lazy thunks for the
counts.

./freqstr2 +RTS -s  -- strings, using strict insertion
   4,754,110,096 bytes allocated in the heap
   2,089,527,240 bytes copied during GC
  27,039,112 bytes maximum residency (66 sample(s))
 613,192 bytes maximum slop
  80 MB total memory in use (2 MB lost due to fragmentation)
./freqstr2 +RTS -s  17.48s user 0.13s system 99% cpu 17.665 total

This reduced maximam memory consumption to one tenth, still bigger than
input corpus, but clearly not too bad.  A bit faster, too, in spite of
probably doing more work.

Using ByteStrings instead, first fromListWith:

./freq +RTS -s
(Just 77432,113931)
   3,880,059,568 bytes allocated in the heap
   1,467,507,808 bytes copied during GC
 174,573,752 bytes maximum residency (14 sample(s))
   8,222,600 bytes maximum slop
 385 MB total memory in use (6 MB lost due to fragmentation)
./freq +RTS -s  14.26s user 0.49s system 99% cpu 14.798 total

About half the memroy of Strings, and 25% faster.  With strict insertion:

./freq2 +RTS -s   -- map using strict insertion
   3,761,614,312 bytes allocated in the heap
 849,806,000 bytes copied during GC
  23,950,328 bytes maximum residency (35 sample(s))
   2,376,904 bytes maximum slop
  58 MB total memory in use (1 MB lost due to fragmentation)
./freq2 +RTS -s  11.14s user 0.13s system 99% cpu 11.295 total

Parallel to the String case, this is a lot more frugal with memory, and
30% faster.  Now, I tried Data.HashMap from the hashmap library:

./freqH1 +RTS -s-- hashmap using fromListWith
   4,552,922,784 bytes allocated in the heap
   2,990,287,536 bytes copied during GC
 401,247,912 bytes maximum residency (14 sample(s))
  42,098,016 bytes maximum slop
 957 MB total memory in use (15 MB lost due to fragmentation)
./freqH1 +RTS -s  15.68s user 1.53s system 99% cpu 17.277 total

./freqH2 +RTS -s   -- hashmap using foldl' insertWith
   4,518,146,968 bytes allocated in the heap
   2,986,973,352 bytes copied during GC
 394,502,832 bytes maximum residency (14 sample(s))
  41,020,040 bytes maximum slop
 957 MB total memory in use (15 MB lost due to fragmentation)
./freqH2 +RTS -s  15.86s user 1.62s system 99% cpu 17.537 total

HashMap doesn't provide a strict insertWith, so this is similar to the
lazy insertions above.  A bit worse, actually, probably due to the
overhead of hashing.

Then, I discovered that Johan's hashmap is a different library, and
thought I'd try that too for completeness.

./freqHS +RTS -s  -- hashmap strict (unordered-containers)
   2,628,628,752 bytes allocated in the heap
 945,571,872 bytes copied during GC
  26,635,744 bytes maximum residency (32 sample(s))
   2,433,504 bytes maximum slop
  66 MB total memory in use (1 MB lost due to fragmentation)

./freqHS +RTS -s  6.90s user 0.16s system 99% cpu 7.082 total

Memory residency like the other strict versions, but really fast,
probably due to faster comparisons of hash values vs comparisons of
strings. 

Conclusion: make sure you are using a strict map, and if your keys are
strings or otherwise have expensive comparisons, unordered-containers is
the library for you.

-k

PS: I also tried mapping 'copy' on the input words to avoid storing
large slices of the input, but it only worsened things:

./freqHS3 +RTS -s 
(Just 77432,113931)
   3,109,585,024 bytes allocated in the heap
 936,724,184 bytes copied during GC
  87,831,888 bytes maximum residency (19 sample(s))
   8,835,440 bytes maximum slop
 164 MB total memory in use (3 MB lost due to fragmentation)
./freqHS3 +RTS -s  12.71s user 0.31s system 99% cpu 13.060 total

Perhaps if you managed to only copy new words it would look better?

PPS: I tried to be careful juggling the results around, but there's
always the possiblity of a mistake.  Caveat lector!  (Or should that be
'cave scriptor'?)

PPPS: There are some small interface annoyances around, it'd be nice 

[Haskell-cafe] Iteratees again (Was: How on Earth Do You Reason about Space?)

2011-06-02 Thread Ketil Malde

By the way, what is the advantage of using iteratees here?  For my
testing, I just used:

  main = printit . freqs . B.words = B.readFile words

(where 'printit' writes some data to stdout just to make sure stuff is
evaluated, and you've already seen some 'freqs' examples)

I have a bunch of old code, parsers etc, which are based on the
'readFile' paradigm:

  type Str = Data.ByteString.Lazy.Char8.ByteString -- usually

  decodeFoo :: Str - Foo
  encodeFoo :: Foo - Str

  readFoo = decodeFoo . readFile 
  writeFoo f = writeFile f . encodeFoo
  hReadFoo = decodeFoo . hRead
  :
  (etc)

This works pretty well, as long as Foo is strict enough that you don't
retain all or huge parts of input, and as long as you can process input
in a forward, linear fashion.  And, like my frequency count above, I
can't really see how this can be made much simpler.

I haven't used iteratees or enumartors in anger, but it appears to me
that they are most useful when the input is unpredictable or needs to be
controlled in some way - for instance, when recv() can return a blocks
of data that may be too little or too much.

Would there be any great advantage to rewriting my stuff to use
iterators?  Or at least, use iterators for new stuff?

As I see it, iterators are complex and the dust is only starting to
settle on implementations and interfaces, and will introduce more
dependencies.  So my instinct is to stick with the worse-is-better
approach, but I'm willing to be educated.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] *GROUP HUG*

2011-06-02 Thread Daniel Fischer
On Thursday 02 June 2011 01:12:37, Tom Murphy wrote:
  How about this:
  
  myFoldr :: (a - b - b) - b - [a] - b
  myFoldr f z xs = foldl' (\s x v - s (x `f` v)) id xs $ z
  
  Cheers,
  Ivan
 
 Great! Now I really can say Come on! It's fun! I can write foldr with
 foldl!
 

Unfortunately, you can't, not quite.

A left fold cannont return anything before it has reached the end of the 
list, so it doesn't work on infinite lists.
With a suitable combining function (and suitable input), a right fold can 
start delivering the result early, hence right folds (can) produce results 
for infinite lists (and my example was meant to draw attention to that 
fact).

Cheers,
Daniel

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Iteratees again (Was: How on Earth Do You Reason about Space?)

2011-06-02 Thread Aleksandar Dimitrov
Hi Ketil,

 By the way, what is the advantage of using iteratees here?  For my
 testing, I just used:

My initial move to iteratees was more a clutch call I made when I was still
using bytestring-trie, and was having immense memory consumption problems.

bytestring-trie uses strict byte strings as an index, and since I was getting
only lazy byte strings, the only way to make them strict would be to use
(S.concat .  L.toChunks) (L and S being the lazy/strict byte string imports,)
which felt *wrong*.

In short, I thought iteratee would give me enough magic fairy dust to actually
have a decent control over how much data I'm holding in RAM at any given point —
that was not the case, since I didn't know about the pointer mechanic of strict
ByteStrings and hence was oblivious to the bad impact that would have on garbage
collection performance.

Even so, I think I can still justify using iteratees in the current design: a)
I don't like lazy IO (conceptually,) b) I'm gonna write a left-fold somewhere
anyway, might as well use a decent infrastructure for it c) I can strictly
control the chunk size, and I'm not going to have any bad effects with
accidental eager evaluation somewhere down the pipe.

c) being the only legitimate reason (though the reason for a) is c) ) —
adjusting the chunk size might actually yield noticeable performance differences
when reading through files that are well into the realm of gigabytes. And the
chunk size limit will protect me from an accidental strict fold or so that
would leave me with a 4GB file in memory.

About a): Lazy IO just doesn't feel right for me. I want my pure computations
to actually be pure. If I put a ' on one of my functions *within* my pure code,
this might have *side effects* — now, instead of reading in only part of the
file, this will demand the *whole* file, and that is *quite* a side effect! So,
suddenly I have to worry about side effects in my pure code. Ugh. That's why I'm
going to continue using iteratees. I don't know if that's the right
justification, but it's a hey, it works for me! justification I can
comfortably live with.

Besides, I don't think the iteratee interface is all that opaque. I found arrows
in HXT, for example, much more difficult to deal with conceptually. (That said,
I'm still using HDBC over Takusen, because the latter's API just didn't make
sense to me.)

Regards,
Aleks


signature.asc
Description: Digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Attoparsec concatenating combinator

2011-06-02 Thread Yitzchak Gale
I often find while using attoparsec and attoparsec-text that I need to
match a number of text parsers consecutively and concatenate the
result. By text parser I mean Parser ByteString for attoparsec and
Parser Text for attoparsec-text.

It seems the best I can do is to collect them all in a list and then
apply concat. But that still copies the text several times.

Is there a combinator that does this without all that copying?
If not, does the internal representation easily admit such
a combinator?

Thanks,
Yitz

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [iteratee] how to do nothing .. properly

2011-06-02 Thread John Lato
Hi Sergey,

I've got an explanation; quite surprisingly it's a bug in enumPure1Chunk.
Even though it is an odd case, I'm surprised that it hasn't come up before
now since enumPure1Chunk appears frequently.

I've just uploaded 0.8.5.0 which has the fix.  There's now an additional
Monoid constraint on enumPure1Chunk, unfortunately.

Thanks very much for reporting this.

John L

On Thu, Jun 2, 2011 at 10:02 AM, Sergey Mironov ier...@gmail.com wrote:

 Ok. I've checked iteratee-0.8.3.0 and 0.8.4.0. Results are same.

 Sergey

 2011/6/2 John Lato jwl...@gmail.com:
  Hi Sergey,
  I can't explain this; maybe it's a bug in enumWith?  I'll look into it.
  Thanks,
  John
 
 
  Message: 20
 
  Date: Thu, 2 Jun 2011 02:46:32 +0400
  From: Sergey Mironov ier...@gmail.com
  Subject: [Haskell-cafe] [iteratee] how to do nothing .. properly
  To: haskell-cafe@haskell.org
  Message-ID: BANLkTimMFRWgH9Nopt-eua+L7jQcGq+u=g...@mail.gmail.com
  Content-Type: text/plain; charset=ISO-8859-1
 
  Hi. Would anybody explain a situation with iter6 and iter7 below?
  Strange thing - first one consumes no intput, while second consumes it
  all, while all the difference is peek  which should do no processing
  (just copy next item in stream and return to user).
  What I am trying to do - is to write an iteratee consuing no input,
  but returning a constant I give to it. I thought (return a) should do
  it, but it seems I was wrong as return actually consumes all unparsed
  stream. iter6 experience tells me that (peekreturn a) is what I
  need, but it's completely confusing and not what I expected.
 
  Thanks,
  Sergey
 
   import Data.Iteratee as I
   import Data.Iteratee.IO
   import Control.Monad
   import Control.Exception
   import Data.ByteString
   import Data.Char
   import Data.String
 
   -- countBytes :: (..., Num b) = Iteratee s m a - Iteratee s m (a, b)
   countBytes i = enumWith i I.length
 
   iter6 = do
  h - countBytes $ (peek  return 0)
  s - I.stream2list
  return (h,s)
 
   iter7 = do
  h - countBytes $ (return 0)
  s - I.stream2list
  return (h,s)
 
   print6 = enumPure1Chunk [1..10] (iter6) = run = print
   print7 = enumPure1Chunk [1..10] (iter7) = run = print
 
 
  Here is example ghci session
 
  *Main print6
  ((0,0),[1,2,3,4,5,6,7,8,9,10])
  -- read 0 items, returns 0
  *Main print7
  ((0,10),[])
  -- read 10 items (???) returns 0
  *Main
 
 
 
  --
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 
  End of Haskell-Cafe Digest, Vol 94, Issue 3
  ***
 
 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [iteratee] how to do nothing .. properly

2011-06-02 Thread Sergey Mironov
I am glad to help! Looks like upgrading to 0.8.5.0 also fixes initial
problem that involved me into testing!

I'll take the opportunity and ask another thing about iteratee: Is it
expected behavior that throwErr consumes all data in current chunk? I
wish it to stop in place and let after-checkErr code to continue the
parsing. Well, I already found solution (or workaround?) - I wrap
Iteratee with ErrorT monad and use ErrorT's raiseError instead of
throwErr. Is it correct?

Here is example code

instance Exception Int

iter4 = do
I.dropWhile (/= 3)
h-I.head
throwErr $ toException $ (-4::Int)  -- doesn't meter what exactly to throw
return h

-- catch the error with checkErr
iter5 = do
(_,b)-countBytes $ I.checkErr $ iter4
s - I.stream2list
return (b,s)

print5 = enumPure1Chunk [1..10] (iter5) = run = print


Thanks a lot!
Sergey

2011/6/2 John Lato jwl...@gmail.com:
 Hi Sergey,

 I've got an explanation; quite surprisingly it's a bug in enumPure1Chunk.
 Even though it is an odd case, I'm surprised that it hasn't come up before
 now since enumPure1Chunk appears frequently.

 I've just uploaded 0.8.5.0 which has the fix.  There's now an additional
 Monoid constraint on enumPure1Chunk, unfortunately.

 Thanks very much for reporting this.

 John L

 On Thu, Jun 2, 2011 at 10:02 AM, Sergey Mironov ier...@gmail.com wrote:

 Ok. I've checked iteratee-0.8.3.0 and 0.8.4.0. Results are same.

 Sergey

 2011/6/2 John Lato jwl...@gmail.com:
  Hi Sergey,
  I can't explain this; maybe it's a bug in enumWith?  I'll look into it.
  Thanks,
  John
 
 
  Message: 20
 
  Date: Thu, 2 Jun 2011 02:46:32 +0400
  From: Sergey Mironov ier...@gmail.com
  Subject: [Haskell-cafe] [iteratee] how to do nothing .. properly
  To: haskell-cafe@haskell.org
  Message-ID: BANLkTimMFRWgH9Nopt-eua+L7jQcGq+u=g...@mail.gmail.com
  Content-Type: text/plain; charset=ISO-8859-1
 
  Hi. Would anybody explain a situation with iter6 and iter7 below?
  Strange thing - first one consumes no intput, while second consumes it
  all, while all the difference is peek  which should do no processing
  (just copy next item in stream and return to user).
  What I am trying to do - is to write an iteratee consuing no input,
  but returning a constant I give to it. I thought (return a) should do
  it, but it seems I was wrong as return actually consumes all unparsed
  stream. iter6 experience tells me that (peekreturn a) is what I
  need, but it's completely confusing and not what I expected.
 
  Thanks,
  Sergey
 
   import Data.Iteratee as I
   import Data.Iteratee.IO
   import Control.Monad
   import Control.Exception
   import Data.ByteString
   import Data.Char
   import Data.String
 
   -- countBytes :: (..., Num b) = Iteratee s m a - Iteratee s m (a, b)
   countBytes i = enumWith i I.length
 
   iter6 = do
      h - countBytes $ (peek  return 0)
      s - I.stream2list
      return (h,s)
 
   iter7 = do
      h - countBytes $ (return 0)
      s - I.stream2list
      return (h,s)
 
   print6 = enumPure1Chunk [1..10] (iter6) = run = print
   print7 = enumPure1Chunk [1..10] (iter7) = run = print
 
 
  Here is example ghci session
 
  *Main print6
  ((0,0),[1,2,3,4,5,6,7,8,9,10])
  -- read 0 items, returns 0
  *Main print7
  ((0,10),[])
  -- read 10 items (???) returns 0
  *Main
 
 
 
  --
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 
  End of Haskell-Cafe Digest, Vol 94, Issue 3
  ***
 
 



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Attoparsec concatenating combinator

2011-06-02 Thread Bryan O'Sullivan
On Thu, Jun 2, 2011 at 7:02 AM, Yitzchak Gale g...@sefer.org wrote:

 It seems the best I can do is to collect them all in a list and then
 apply concat. But that still copies the text several times.


Right. I'd like a no-copy combinator for the same reasons, but I think it's
impossible to do without some low-level support.


 If not, does the internal representation easily admit such a combinator?


Not very easily. Internally, attoparsec maintains just three pieces of data
for its state:

   - The current input
   - Any input we received via continuations, in case we need to backtrack
   - A flag that denotes whether we were fed EOF by a continuation

There are no line numbers, no bytes consumed counters, nothing else. If
there was a bytes consumed counter, it would be possible to write a
try-like combinator that would hold onto the current input, run a parser,
tack on any input received via continuations to the original input, and then
use the counter to slice off a portion of that bytestring without copying. I
can't think of another way to do it. Adding that counter would be a moderate
amount of work, and would presumably have a negative effect on performance.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Oracle Sessions in Takusen

2011-06-02 Thread Kevin Quick

Dmitry,

I'm not directly familiar with Takusen or its use with OracleDB, but I  
would hazard a guess that the withSession is doing FFI resource management  
and that resources obtained inside the withSession environment are no  
longer valid outside of the withSession.


If this is the case then I would expect the following to work:

   replicateM 2 (do
withSession (connect x x x) (do
  res - doQuery ...
  liftIO $ print res
)
)

If this really is the case then it seems that withSession shouldn't be  
exporting FFI-based resources.


-KQ

On Wed, 01 Jun 2011 07:44:10 -0700, Dmitry Olshansky  
olshansk...@gmail.com wrote:



Hello,

Could anyone explain strange behavior of Takusen with OracleDB (OraClient
11.x)? Several sequential sessions give Seqmentation Fault error. In  
case

of nested sessions it works well.

{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Database.Oracle.Enumerator
import Control.Monad(replicateM)
import Control.Monad.Trans(liftIO)
main = do
{-
-- This gives an Segmentation Fault for the second session

replicateM 2 (do
res - withSession (connect x x x)  (do
doQuery (sql SELECT dummy FROM dual) (\(d::String)
(_::Maybe String) - result' $ Just d) Nothing
)
print res
)
-}

-- This is works well

withSession (connect x x x)  (do
r1 - doQuery (sql SELECT dummy FROM dual) (\(d::String)
(_::Maybe String) - result' $ Just d) Nothing
liftIO $ print r1
liftIO $ withSession (connect x x x)  (do
r2 - doQuery (sql SELECT dummy FROM dual)
(\(d::String) (_::Maybe String) - result' $ Just d) Nothing
liftIO $ print r2
)
)
Best regards,
Dmitry



--
-KQ

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] *GROUP HUG*

2011-06-02 Thread Ertugrul Soeylemez
Alberto G. Corona  agocor...@gmail.com wrote:

 Haskell is an academic asset as well as a fun asset.

I cannot agree with this for practical reasons.  I'm using Haskell for
real world commercial applications, and I'm very productive with it.

There is however a variation of this statement, with which I could
agree, namely:  Learning Haskell will pay off much less than learning
PHP, if your goal is to find a job.  It takes a lot longer and there are
a lot less companies in need of Haskell programmers.


Greets,
Ertugrul


-- 
nightmare = unsafePerformIO (getWrongWife = sex)
http://ertes.de/



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] *GROUP HUG*

2011-06-02 Thread Ertugrul Soeylemez
Ivan Tarasov ivan.tara...@gmail.com wrote:

 myFoldr :: (a - b - b) - b - [a] - b
 myFoldr f z xs = foldl' (\s x v - s (x `f` v)) id xs $ z

That's not foldr.  It's a function similar to foldr in Haskell and equal
to foldr in a different language, which lacks bottom.


Greets,
Ertugrul


-- 
nightmare = unsafePerformIO (getWrongWife = sex)
http://ertes.de/



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] *GROUP HUG*

2011-06-02 Thread Yves Parès
 Learning Haskell will pay off much less than learning PHP, if your goal is
to find a job.

Amen.

 I cannot agree with this for practical reasons.  I'm using Haskell for
 real world commercial applications, and I'm very productive with it.

I wish so much I could say that... Out of curiosity, what are you using
Haskell for?


2011/6/2 Ertugrul Soeylemez e...@ertes.de

 Alberto G. Corona  agocor...@gmail.com wrote:

  Haskell is an academic asset as well as a fun asset.

 I cannot agree with this for practical reasons.  I'm using Haskell for
 real world commercial applications, and I'm very productive with it.

 There is however a variation of this statement, with which I could
 agree, namely:  Learning Haskell will pay off much less than learning
 PHP, if your goal is to find a job.  It takes a lot longer and there are
 a lot less companies in need of Haskell programmers.


 Greets,
 Ertugrul


 --
 nightmare = unsafePerformIO (getWrongWife = sex)
 http://ertes.de/



 ___
 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] Oracle Sessions in Takusen

2011-06-02 Thread Alistair Bayley
On 3 June 2011 05:35, Kevin Quick qu...@sparq.org wrote:
 Dmitry,

 I'm not directly familiar with Takusen or its use with OracleDB, but I would
 hazard a guess that the withSession is doing FFI resource management and
 that resources obtained inside the withSession environment are no longer
 valid outside of the withSession.

 If this is the case then I would expect the following to work:

   replicateM 2 (do
        withSession (connect x x x) (do
              res - doQuery ...
              liftIO $ print res
            )
        )

 If this really is the case then it seems that withSession shouldn't be
 exporting FFI-based resources.

 -KQ

You're right, withSession shouldn't be exporting FFI obtained
resources, and I don't think it does. There are some known issues with
the Oracle code, where it allows buffers to fall out of reference (and
thus be gc'd) before the C libs have finished with them, thereby
causing segfaults. The known problems are around bind variable
buffers, so this looks like a new issue.

At least we're collecting a nice corpus of programs that cause the
Oracle backend to fail :-) I'd love to have more time to work on it...

If you don't need the Oracle-specific functionality, for now I suggest
using the ODBC driver as a substitute, as this seems to be (more)
reliable.

Alistair

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Iteratees again (Was: How on Earth Do You Reason about Space?)

2011-06-02 Thread dm-list-haskell-cafe
At Thu, 02 Jun 2011 13:52:52 +0200,
Ketil Malde wrote:
 
 I have a bunch of old code, parsers etc, which are based on the
 'readFile' paradigm:
 
   type Str = Data.ByteString.Lazy.Char8.ByteString -- usually
 
   decodeFoo :: Str - Foo
   encodeFoo :: Foo - Str
 
   readFoo = decodeFoo . readFile 
   writeFoo f = writeFile f . encodeFoo
   hReadFoo = decodeFoo . hRead
   :
   (etc)
 
 This works pretty well, as long as Foo is strict enough that you don't
 retain all or huge parts of input, and as long as you can process input
 in a forward, linear fashion.  And, like my frequency count above, I
 can't really see how this can be made much simpler.

This is fine if you never have parse errors and always read to the end
of the file.  Otherwise, the code above is incorrect and ends up
leaking file descriptors.  In general, it is very hard to write
parsers that parse every possible input and never fail.  Thus, for
anything other than a toy program, your code actually has to be:

readFoo path = bracket (hOpen path) hclose $
hGetContents = (\s - return $! decodeFoo s)

Which is still not guaranteed to work if Foo contains thunks, so then
you end up having to write:

readFoo path = bracket (hOpen path) hclose $ \h - do
  s - hGetContents h
  let foo = decodeFoo s
  deepseq foo $ return foo

Or, finally, what a lot of code falls back to, inserting gratuitous
calls to length:

readFoo path = bracket (hOpen path) hclose $ \h - do
  s - hGetContents h
  length s `seq` return decodeFoo s

The equivalent code with the iterIO package would be:

readFoo path = enumFile path |$ fooI

which seems a lot simpler to me...

 Would there be any great advantage to rewriting my stuff to use
 iterators?  Or at least, use iterators for new stuff?

In addition to avoiding edge cases like leaked file descriptors and
memory, one of the things I discovered in implementing iterIO is that
it's really handy to have your I/O functions be the same as your
parsing combinators.  So iteratees might actually admit a far simpler
implementation of decodeFoo/fooI.

More specifically, imagine that you have decodeFoo, and now want to
implement decodeBar where a Bar includes some Foos.  Unfortunately,
having an implementation of decodeFoo in-hand doesn't help you
implement decodeBar.  You'd have to re-write your function to return
residual input, maybe something like:

decodeFooReal :: String - (Foo, String)

decodeFoo :: String - Foo
decodeFoo = fst . decodeFooReal

and now you implement decodeBar in terms of decodeFooReal, but you
have to pass around residual input explicitly, handle parsing failures
explicitly, etc.

 As I see it, iterators are complex and the dust is only starting to
 settle on implementations and interfaces, and will introduce more
 dependencies.  So my instinct is to stick with the worse-is-better
 approach, but I'm willing to be educated.

I fully agree with the point about dependencies and waiting for the
dust to settle, though I hope a lot of that changes in a year or so.
However, iterIO should already significantly reduce the complexity.

David

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] *GROUP HUG*

2011-06-02 Thread Ertugrul Soeylemez
Yves Parès limestr...@gmail.com wrote:

  I cannot agree with this for practical reasons.  I'm using Haskell
  for real world commercial applications, and I'm very productive with
  it.

 I wish so much I could say that... Out of curiosity, what are you
 using Haskell for?

I use the Yesod web framework for web development and a combination of
many libraries for network servers.


Greets,
Ertugrul


-- 
nightmare = unsafePerformIO (getWrongWife = sex)
http://ertes.de/



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: fix-imports-0.1.0

2011-06-02 Thread Evan Laforge
I just uploaded a new package called fix-imports.

Maintaining the import block is one of the less fun things I do while
writing haskell.  So I wrote a little program to do that for me.
Basically, I edit source, then hit ,a in vim, and it figures out which
modules need to be imported, which imports are not needed, and sorts
and formats the import list.  I've been using it for the last week or
so and it seems to be working ok, so I decided to upload it to hackage
in case anyone else doesn't like maintaining import lists manually.

The catch: it only works for qualified imports.

Here's copy paste from the package description:

A small standalone program to manage the import block of a haskell
program. It will try to add import lines for qualified names with no
corresponding import, remove unused import lines, and sort the import
block according to some heuristic you can define. This only works for
qualified imports! Unqualified imports are left untouched.

It's most convenient if bound to an editor key.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] License of hslogger, HDBC, etc.

2011-06-02 Thread John Goerzen

Hi Jon  all,

I've decided that I'm OK with re-licensing hslogger, HDBC, and well all 
of my Haskell libraries (not end programs) under 3-clause BSD.


My schedule is extremely tight right now but if someone wants to send me 
patches for these things I will try to apply them within the week.


-- John

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] *GROUP HUG*

2011-06-02 Thread Michael Litchard
I disagree. I'm by no means proficient in Haskell. And, I never
bothered learning PHP. I will when I need to. PHP programmers are a
dime a dozen. It's been my experience that Haskell is a tool one may
use to distinguish oneself from the hoi-poloi. This is important when
you live in an area where the baker down the street has a CS degree.

On Thu, Jun 2, 2011 at 11:52 AM, Yves Parès limestr...@gmail.com wrote:
 Learning Haskell will pay off much less than learning PHP, if your goal is
 to find a job.

 Amen.

 I cannot agree with this for practical reasons.  I'm using Haskell for
 real world commercial applications, and I'm very productive with it.

 I wish so much I could say that... Out of curiosity, what are you using
 Haskell for?


 2011/6/2 Ertugrul Soeylemez e...@ertes.de

 Alberto G. Corona  agocor...@gmail.com wrote:

  Haskell is an academic asset as well as a fun asset.

 I cannot agree with this for practical reasons.  I'm using Haskell for
 real world commercial applications, and I'm very productive with it.

 There is however a variation of this statement, with which I could
 agree, namely:  Learning Haskell will pay off much less than learning
 PHP, if your goal is to find a job.  It takes a lot longer and there are
 a lot less companies in need of Haskell programmers.


 Greets,
 Ertugrul


 --
 nightmare = unsafePerformIO (getWrongWife = sex)
 http://ertes.de/



 ___
 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



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Names for pretty-printing combinators

2011-06-02 Thread Henning Thielemann
Casey McCann schrieb:
 One drastic approach I've used in personal libraries--operator-heavy
 EDSLs specifically--is to define everything first with alphanumeric
 names, then put operators in their own modules. In some cases I'd have
 three such modules: One providing a minimal set of operators that don't
 clash with anything significant, one providing a larger set of operators
 that clash with one or more common modules (often deliberately, e.g.
 duplicating Arrow combinators for some type with similar semantics but
 no valid Arrow instance), and one providing a bunch of gratuitous
 Unicode operators that look pretty in my code editor but I don't know
 how to type in GHCi.

I use explicit imports in order to avoid infix operator clashes.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] License of hslogger, HDBC, etc.

2011-06-02 Thread Nicolas Wu
On 2 June 2011 22:20, John Goerzen jgoer...@complete.org wrote:
 Hi Jon  all,

 I've decided that I'm OK with re-licensing hslogger, HDBC, and well all of
 my Haskell libraries (not end programs) under 3-clause BSD.

Awesome, thanks very much!

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] License of hslogger, HDBC, etc.

2011-06-02 Thread Vo Minh Thu
2011/6/2 John Goerzen jgoer...@complete.org:
 Hi Jon  all,

 I've decided that I'm OK with re-licensing hslogger, HDBC, and well all of
 my Haskell libraries (not end programs) under 3-clause BSD.

 My schedule is extremely tight right now but if someone wants to send me
 patches for these things I will try to apply them within the week.

Thanks!

What was your line of reasoning to make the switch?

Cheers,
Thu

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Status of Haskell + Mac + GUIs graphics

2011-06-02 Thread Conal Elliott
Thanks for these instructions, John. I had to adapt to my 32-bit ghc by
adding +universal to the 'port install' lines. I did not find a
gtkglext.dpatch. Has it been roled into the gtkglext darcs repo? I guess
not, since the last update was Nov 7 (Tag 0.12.0), according to 'darcs
changes'.

Eventually everything compiled, but I get a linking error. When building an
executable, I get

Linking dist/build/TestImage/TestImage ...
Undefined symbols:
  _gdk_gl_config_get_screen, referenced from:
  _s8kj_info in libHSgtkglext-0.12.0.a(Config.o)
  _gdk_gl_context_is_direct, referenced from:
  _s73Y_info in libHSgtkglext-0.12.0.a(Context.o)
  _gdk_gl_context_get_gl_config, referenced from:
  _s777_info in libHSgtkglext-0.12.0.a(Context.o)
  _gdk_gl_context_get_render_type, referenced from:
  _s7lg_info in libHSgtkglext-0.12.0.a(Context.o)
  _gdk_gl_context_get_share_list, referenced from:
  _s75v_info in libHSgtkglext-0.12.0.a(Context.o)
  _gdk_gl_config_get_depth, referenced from:
  _s8r6_info in libHSgtkglext-0.12.0.a(Config.o)

In ghci:

*Main main
Loading package array-0.3.0.2 ... linking ... done.
Loading package bytestring-0.9.1.10 ... linking ... done.
...
Loading package cairo-0.12.0 ... linking ... done.
Loading package glib-0.12.0 ... linking ... done.
Loading package gio-0.12.0 ... linking ... done.
Loading package pango-0.12.0 ... linking ... done.
Loading package gtk-0.12.0 ... linking ... done.
Loading package gtkglext-0.12.0 ... linking ... interactive:
unknown symbol `_gdk_gl_context_get_render_type'
ghc: unable to load package `gtkglext-0.12.0'
*Main

Are these failures about the missing patch?

  - Conal

On Thu, May 26, 2011 at 3:03 AM, John Lato jwl...@gmail.com wrote:

 fltk definitely has some good points, but I've always found it hideously
 ugly.  Of course the default gtk on osx is ugly too, but some of the
 available themes are nice.

 However, getting gtk with OpenGL on osx was fairly easy.  Everything worked
 out of the box except gtkglext (Haskell package).  I've submitted some
 patches for that which hopefully will be applied to the repo soon.

 This is what I used:

 git
 darcs
 ghc-7.0.3 (self-compiled)
 cabal-install
 macports gtk2 +no_x11 +quartz
 macports gtkglext +no_x11 +quartz
 gtk2hs from source
 gtkglext (Haskell) from source


 I use a self-compiled ghc, but this should work with any ghc.  Mixing ghc
 and macports can cause problems with libiconv, but the solutions are pretty
 well-known.  Since I compile ghc, I configure it to use macports's libiconv
 so there aren't any conflicts.


  sudo port install gtkglext +no_x11 +quartz
 (wait a while...)
  darcs get --lazy http://code.haskell.org/gtk2hs
  cd gtk
  cabal install gtk2hs-buildtools
  chmod +x bootstrap.sh
  ./bootstrap.sh -fhave-quartz-gtk
 (wait a while...)
  cd ..
  darcs get --lazy http://code.haskell.org/gtkglext
  cd gtkglext
  darcs apply gtkglext.dpatch
  cabal install


 Until the source tree gets patched, you'll have to manually apply the patch
 bundle.

 If you want to avoid macports, it should be possible to use gtk-osx and
 gtkglext from source instead.  However, I've found gtk-osx to be unstable
 and quite difficult to build in the past, so I'd strongly recommend
 macports, at least for now.  The source install of gtkglext works just fine
 and can be used with macports gtk2 (I tested this).  Since this path already
 uses macports there's not much benefit though.

 Cheers,
 John L


 On Wed, May 25, 2011 at 9:07 PM, Evan Laforge qdun...@gmail.com wrote:

 fltk supports OpenGL on windows, X11, and OS X, though I've never used
 it.  The thing it doesn't have is a haskell binding, but as I
 mentioned I just bind whatever I need when I need it and since I don't
 need much it's easy.  Dunno if this applies in your case though.

 Maybe it's my NIH, but I like to start with something too simple and
 add what I need rather than start with something that has more than I
 need and try to get it working.

 On Wed, May 25, 2011 at 11:58 AM, Conal Elliott co...@conal.net wrote:
  Thanks, John. Encouraging bit of news. Please do let us know what you
 learn
  when you try.   - Conal
 
  On Tue, May 24, 2011 at 1:28 AM, John Lato jwl...@gmail.com wrote:
 
  You can use gtkglext to get OpenGL support.  With the official release
 of
  gtkglext-1.2.0 there's a bit of hacking involved (that was probably me
  you're referring to), but it looks like the repo head has native
 Quartz.
  With any luck, you just need to build gtkglext from the repo, then the
  gtkglext package.
 
  I might have some time to try this later today; I'll report back if I
 get
  results.
 
  John Lato
 
  On Tue, May 24, 2011 at 6:01 AM, Conal Elliott co...@conal.net
 wrote:
 
  Last I tried, there wasn't native support for OpenGL with gtk, and I
 need
  OpenGL. Then more recently, I heard of some progress in that area, but
 

Re: [Haskell-cafe] *GROUP HUG*

2011-06-02 Thread David Leimbach
I got hired at a company because one of the interviewers was impressed that
I taught myself Haskell.  I basically never use it at work, but I did in my
old job.

Dave

On Thu, Jun 2, 2011 at 2:23 PM, Michael Litchard mich...@schmong.orgwrote:

 I disagree. I'm by no means proficient in Haskell. And, I never
 bothered learning PHP. I will when I need to. PHP programmers are a
 dime a dozen. It's been my experience that Haskell is a tool one may
 use to distinguish oneself from the hoi-poloi. This is important when
 you live in an area where the baker down the street has a CS degree.

 On Thu, Jun 2, 2011 at 11:52 AM, Yves Parès limestr...@gmail.com wrote:
  Learning Haskell will pay off much less than learning PHP, if your goal
 is
  to find a job.
 
  Amen.
 
  I cannot agree with this for practical reasons.  I'm using Haskell for
  real world commercial applications, and I'm very productive with it.
 
  I wish so much I could say that... Out of curiosity, what are you using
  Haskell for?
 
 
  2011/6/2 Ertugrul Soeylemez e...@ertes.de
 
  Alberto G. Corona  agocor...@gmail.com wrote:
 
   Haskell is an academic asset as well as a fun asset.
 
  I cannot agree with this for practical reasons.  I'm using Haskell for
  real world commercial applications, and I'm very productive with it.
 
  There is however a variation of this statement, with which I could
  agree, namely:  Learning Haskell will pay off much less than learning
  PHP, if your goal is to find a job.  It takes a lot longer and there are
  a lot less companies in need of Haskell programmers.
 
 
  Greets,
  Ertugrul
 
 
  --
  nightmare = unsafePerformIO (getWrongWife = sex)
  http://ertes.de/
 
 
 
  ___
  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
 
 

 ___
 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] *GROUP HUG*

2011-06-02 Thread Michael Litchard
Being able to use Haskell at such an early stage of my programming
career has given me high expectations of what comes next.

On Thu, Jun 2, 2011 at 3:22 PM, David Leimbach leim...@gmail.com wrote:
 I got hired at a company because one of the interviewers was impressed that
 I taught myself Haskell.  I basically never use it at work, but I did in my
 old job.
 Dave

 On Thu, Jun 2, 2011 at 2:23 PM, Michael Litchard mich...@schmong.org
 wrote:

 I disagree. I'm by no means proficient in Haskell. And, I never
 bothered learning PHP. I will when I need to. PHP programmers are a
 dime a dozen. It's been my experience that Haskell is a tool one may
 use to distinguish oneself from the hoi-poloi. This is important when
 you live in an area where the baker down the street has a CS degree.

 On Thu, Jun 2, 2011 at 11:52 AM, Yves Parès limestr...@gmail.com wrote:
  Learning Haskell will pay off much less than learning PHP, if your goal
  is
  to find a job.
 
  Amen.
 
  I cannot agree with this for practical reasons.  I'm using Haskell for
  real world commercial applications, and I'm very productive with it.
 
  I wish so much I could say that... Out of curiosity, what are you using
  Haskell for?
 
 
  2011/6/2 Ertugrul Soeylemez e...@ertes.de
 
  Alberto G. Corona  agocor...@gmail.com wrote:
 
   Haskell is an academic asset as well as a fun asset.
 
  I cannot agree with this for practical reasons.  I'm using Haskell for
  real world commercial applications, and I'm very productive with it.
 
  There is however a variation of this statement, with which I could
  agree, namely:  Learning Haskell will pay off much less than learning
  PHP, if your goal is to find a job.  It takes a lot longer and there
  are
  a lot less companies in need of Haskell programmers.
 
 
  Greets,
  Ertugrul
 
 
  --
  nightmare = unsafePerformIO (getWrongWife = sex)
  http://ertes.de/
 
 
 
  ___
  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
 
 

 ___
 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] Attoparsec concatenating combinator

2011-06-02 Thread Mario Blažević
On Thu, Jun 2, 2011 at 10:02 AM, Yitzchak Gale g...@sefer.org wrote:
 I often find while using attoparsec and attoparsec-text that I need to
 match a number of text parsers consecutively and concatenate the
 result. By text parser I mean Parser ByteString for attoparsec and
 Parser Text for attoparsec-text.

   I don't know if this helps, but the incremental-parser library has
exactly the combinator you're looking for.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Iteratees again (Was: How on Earth Do You Reason about Space?)

2011-06-02 Thread wren ng thornton

On 6/2/11 8:59 AM, Aleksandar Dimitrov wrote:

Hi Ketil,


By the way, what is the advantage of using iteratees here?  For my
testing, I just used:


My initial move to iteratees was more a clutch call I made when I was still
using bytestring-trie, and was having immense memory consumption problems.


bytestring-trie also (intentionally) uses ByteString slicing in order to 
minimize copying. It does so semi-intelligently--- ensuring that of the 
two sharing options it chooses the one with a shorter spur. About half 
the time that spur will be used by continuing down the trie, but you can 
still end up with unwanted overhead especially if you're intermittently 
removing keys from the trie.


I've been meaning to add functions to remove spurs (because sometimes 
the memory is more important than the running time) and meaning to add 
various other upgrades. I've just been too busy with other code for the 
last year or so.


--
Live well,
~wren

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe