Re: [Haskell-cafe] How does one create an input handle bound to a string instead of a file?

2013-02-28 Thread Ganesh Sittampalam
Hi, On 27/02/2013 20:38, John D. Ramsdell wrote: How does one create a value of type System.IO.Handle for reading that takes its input from a string instead of a file? I'm looking for the equivalent of java.io.StringReader in Java. Thanks in advance.

[Haskell-cafe] Problem accessing Hackage

2013-02-28 Thread Roman Cheplyaka
I have this weird problem accessing hackage, when the first response gets delayed by 30 seconds: http://superuser.com/q/557271/53951 Does anyone else experience it? (No need to reply with works for me — I know that it works for most people.) Any clues about what can be the problem? Roman

Re: [Haskell-cafe] The state of binary (de)serialization

2013-02-28 Thread wren ng thornton
On 2/27/13 2:17 AM, Vincent Hanquez wrote: Two major problems of lazy bytestrings is that: * you can't pass it to a C bindings easily. * doing IO with it without rewriting the chunks, can sometimes (depending how the lazy bytestring has been produced) result in a serious degradation of

Re: [Haskell-cafe] The state of binary (de)serialization

2013-02-28 Thread Nicolas Trangez
On Thu, 2013-02-28 at 01:22 -0800, wren ng thornton wrote: On 2/27/13 2:17 AM, Vincent Hanquez wrote: Two major problems of lazy bytestrings is that: * you can't pass it to a C bindings easily. * doing IO with it without rewriting the chunks, can sometimes (depending how the lazy

Re: [Haskell-cafe] The state of binary (de)serialization

2013-02-28 Thread Nicolas Trangez
On Mon, 2013-02-25 at 11:59 -0800, Johan Tibell wrote: On Mon, Feb 25, 2013 at 4:30 AM, Nicolas Trangez nico...@incubaid.comwrote: - cereal supports chunk-based 'partial' parsing (runGetPartial). It looks like support for this is introduced in recent versions of 'binary' as well

Re: [Haskell-cafe] The state of binary (de)serialization

2013-02-28 Thread Nicolas Trangez
On Wed, 2013-02-27 at 07:49 +0100, Vincent Hanquez wrote: On Mon, Feb 25, 2013 at 01:30:40PM +0100, Nicolas Trangez wrote: ... I've been looking at the same thing lately, and i've been quite surprised, to say the least, by the usual go-to packages (cereal, binary). Performance wise this is

[Haskell-cafe] Question about forkIO

2013-02-28 Thread C K Kashyap
Hi All, Say I have a haskell function 'f' that does a forkIO and starts an action a. I create a DLL of this haskell code and inovke f from C. Can I expect the a to continue to run once f has returned to C? Regards, Kashyap ___ Haskell-Cafe mailing

Re: [Haskell-cafe] Problem accessing Hackage

2013-02-28 Thread Roman Cheplyaka
Ok, I got what seems to be the correct answer: http://superuser.com/a/558715/53951 In a nutshell, the misconfiguration of my ISP's DNS results in reverse DNS queries of my IP address timing out. So now my questions are: - can anyone confirm that hackage indeed attempts to do reverse DNS

Re: [Haskell-cafe] How does one create an input handle bound to a string instead of a file?

2013-02-28 Thread John D. Ramsdell
I think I wasn't clear about my question. I want something that creates a value of type System.IO.Handle. You see, I have a high performance S-expression parser that I'd like to use in GHCi reading strings while at the command loop. Here is more details on my module SExpr that exports the SExpr

Re: [Haskell-cafe] How does one create an input handle bound to a string instead of a file?

2013-02-28 Thread Ganesh Sittampalam
Hi John, Using bytestring-handle, you can get this with something like stringHandle :: String - Handle stringHandle s = readHandle False (Data.ByteString.Char8.pack s) [note the complete disregard of encoding issues in the use of Data.ByteString.Char8] Cheers, Ganesh On 28/02/2013 13:32,

Re: [Haskell-cafe] How does one create an input handle bound to a string instead of a file?

2013-02-28 Thread John D. Ramsdell
I couldn't find the mkHandle function in the source linked to the specified Haddock generated documentation page. If there is a consensus that others besides myself would like a function with the signature stringHandle :: String - IO (Handle) I'd be happy to contribute code. I'd need help as I

Re: [Haskell-cafe] How does one create an input handle bound to a string instead of a file?

2013-02-28 Thread John D. Ramsdell
I see now. I read the source code incorrectly. Now I know what to do. John On Thu, Feb 28, 2013 at 8:40 AM, Ganesh Sittampalam gan...@earth.li wrote: Hi John, Using bytestring-handle, you can get this with something like stringHandle :: String - Handle stringHandle s = readHandle False

Re: [Haskell-cafe] How does one create an input handle bound to a string instead of a file?

2013-02-28 Thread Erik Hesselink
Is your parser impure? I would expect a function from String/Text/ByteString to Maybe (SExpr Pos). Then you have no need for a Handle. Regards, Erik On Thu, Feb 28, 2013 at 2:32 PM, John D. Ramsdell ramsde...@gmail.com wrote: I think I wasn't clear about my question. I want something that

Re: [Haskell-cafe] Question about forkIO

2013-02-28 Thread C K Kashyap
Just to clarify, here is the sample haskell code that I am using - {-# LANGUAGE ForeignFunctionInterface #-} module Glue where import Foreign.C.String import qualified Control.Concurrent as CC funHaskell :: CString - IO Int funHaskell cstr = do putStrLn Haskell function called str -

Re: [Haskell-cafe] Question about forkIO

2013-02-28 Thread Brandon Allbery
On Thu, Feb 28, 2013 at 6:09 AM, C K Kashyap ckkash...@gmail.com wrote: Say I have a haskell function 'f' that does a forkIO and starts an action a. I create a DLL of this haskell code and inovke f from C. Can I expect the a to continue to run once f has returned to C? While you're off in C

[Haskell-cafe] Implementing name-mangling in GHC?

2013-02-28 Thread Ismael Figueroa Palet
Hi café, I'm working on a small project, and I need to rename all ocurrences of a data type in a module. For instance, if the program is module Foo where data Bar fun :: Bar - Bar fun = ... I'd like that during compilation the module looks as if it was written like: module Foo where data

Re: [Haskell-cafe] How does one create an input handle bound to a string instead of a file?

2013-02-28 Thread John D. Ramsdell
The actual parser is a bit more complicated than I let on. First, it's important that not all of a file be read at the same time as the files can be huge. Second, it keeps track of column row position information as an IORef, which makes sense because the ref is bundled in a structure with the

Re: [Haskell-cafe] How to return a network connection to C

2013-02-28 Thread Niklas Hambüchen
What data type are you dealing with exactly? If you have a socket, I guess you can just use it from C (via FFI). PS: By Network.Connection, do you mean http://hackage.haskell.org/package/network-connection-0.1.1 ? Seems deprecated. On 28/02/13 06:14, C K Kashyap wrote: Hi, I am using

Re: [Haskell-cafe] Question about forkIO

2013-02-28 Thread Donn Cave
Quoth C K Kashyap ckkash...@gmail.com, ... Say I have a haskell function 'f' that does a forkIO and starts an action a. I create a DLL of this haskell code and inovke f from C. Can I expect the a to continue to run once f has returned to C? Once control returns to f's caller, outside of the

Re: [Haskell-cafe] How to return a network connection to C

2013-02-28 Thread C K Kashyap
I am using http://hackage.haskell.org/package/connection. So I create network connection in Haskell getConnection :: IO Connection I'd like this connection to be returned to C so that subsequent calls from C can send in the connection handle. Regards, Kashyap On Thu, Feb 28, 2013 at 9:04 PM,

Re: [Haskell-cafe] How to return a network connection to C

2013-02-28 Thread Krzysztof Skrzętnicki
If I understand you correctly you need a StablePtr to your Connection value. Please see: http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.6.0.1/Foreign-StablePtr.html Best regards, Krzysztof Skrzętnicki On Thu, Feb 28, 2013 at 6:31 PM, C K Kashyap ckkash...@gmail.com wrote: I am

Re: [Haskell-cafe] How to return a network connection to C

2013-02-28 Thread Donn Cave
Quoth C K Kashyap ckkash...@gmail.com, I am using http://hackage.haskell.org/package/connection. So I create network connection in Haskell getConnection :: IO Connection I'd like this connection to be returned to C so that subsequent calls from C can send in the connection handle.

Re: [Haskell-cafe] How to return a network connection to C

2013-02-28 Thread C K Kashyap
Okay, for now I have figured out a working solution to the original problem I was facing . I just forkIO another IO action that does the actual network work and in addition, it opens a server socket and waits for commands. The calls from C reach Haskell, from where a connection is made to

Re: [Haskell-cafe] Question about forkIO

2013-02-28 Thread C K Kashyap
Hey Donn .. thanks, it turns out that threads do resume!!! This is how I got my gmail stuff working. I only have a doubt if the TCP keep/alive stuff continues to happen or not Regards, Kashyap On Thu, Feb 28, 2013 at 9:07 PM, Donn Cave d...@avvanta.com wrote: Quoth C K Kashyap

Re: [Haskell-cafe] How to return a network connection to C

2013-02-28 Thread Donn Cave
Quoth C K Kashyap ckkash...@gmail.com, Hey Donn ... when you say, implement the IO in C, you also imply implementing the SSL stuff too right? Yes, if you need encrypted I/O from C. Donn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Split and substitution using regex-pcre

2013-02-28 Thread Alistair Bayley
You cannot bend the split package to your needs? http://hackage.haskell.org/packages/archive/split/0.2.1.2/doc/html/Data-List-Split.html Some combination of splitWhen and a pcre-based predicate? On 24 February 2013 22:44, Simon Marechal si...@banquise.net wrote: I could not find the

Re: [Haskell-cafe] Split and substitution using regex-pcre

2013-02-28 Thread Brent Yorgey
On Fri, Mar 01, 2013 at 08:30:20AM +1300, Alistair Bayley wrote: You cannot bend the split package to your needs? http://hackage.haskell.org/packages/archive/split/0.2.1.2/doc/html/Data-List-Split.html Some combination of splitWhen and a pcre-based predicate? This won't work; splitWhen

[Haskell-cafe] Haskell Weekly News: Issue 260

2013-02-28 Thread Daniel Santa Cruz
Welcome to issue 260 of the HWN, an issue covering crowd-sourced bits of information about Haskell from around the web. This issue covers the week of February 17 to 23, 2013. Quotes of the Week * danharaj: zygohistobfuscatory maintainomorphism * merijn: after a week you can delete 80% of

Re: [Haskell-cafe] The state of binary (de)serialization

2013-02-28 Thread Andrew Cowie
On Mon, 2013-02-25 at 11:59 -0800, Johan Tibell wrote: Simon's builder (originally developed in blaze-binary) has been merged into the bytestring package. I've been meaning to ask: does this mean that ByteString's concat and append functions will now be implemented in terms of Builder

Re: [Haskell-cafe] ANN: Nomyx 0.1 beta, the game where you can change the rules

2013-02-28 Thread Chris Wong
On Thu, Feb 28, 2013 at 1:26 PM, Brandon Allbery allber...@gmail.com wrote: On Wed, Feb 27, 2013 at 8:37 AM, Corentin Dupont corentin.dup...@gmail.com wrote: Hi Chris, Thanks! That's true for the user number. What should I do? Encrypt it? It's not that you have a user number, or even that

Re: [Haskell-cafe] Parser left recursion

2013-02-28 Thread Paul Callaghan
Hi Another alternative is this Haskell library: https://github.com/paulcc/xsaiga This is a combinator library which is suitable for mid-scale NLP work, so handles left recursion and (high amounts of) ambiguity to produce a packed result (which can be decoded to a list of results if required). It