Re: [Haskell-cafe] Unexpected behaviour with send and send-buffer setting

2013-09-03 Thread Joey Adams
On Tue, Sep 3, 2013 at 6:56 PM, Simon Yarde simonya...@me.com wrote: I'm new to Haskell and have reached an impasse in understanding the behaviour of sockets. The crux of my line of enquiry is this; how can my application know when to pause in generating its chunked output if send doesn't

Re: [Haskell-cafe] PPC binaries for GHC 7.x?

2013-08-21 Thread Joey Adams
On Wed, Aug 21, 2013 at 4:55 AM, Rogan Creswick cresw...@gmail.com wrote: Does anyone have PPC binaries for GHC 7.x? I've been trying to help a PPC user compile a large haskell application, and it (and it's dependencies) require a newer ghc; the latest ppc binaries we've found are for 6.10,

Re: [Haskell-cafe] deriving Data.HashTable - stack overflow

2013-08-08 Thread Joey Adams
On Thu, Aug 8, 2013 at 12:22 PM, Lyle Kopnicky li...@qseep.net wrote: ... So I went to the Data.Hashable page and looked up examples on how to derive a Hashable instance for my datatype: http://hackage.haskell.org/packages/archive/hashable/latest/doc/html/Data-Hashable.html The problem

Re: [Haskell-cafe] ordNub

2013-07-14 Thread Joey Adams
On Sun, Jul 14, 2013 at 7:31 AM, Clark Gaebel cgae...@uwaterloo.ca wrote: Similarly, I've always used: import qualified Data.HashSet as S nub :: Hashable a = [a] - [a] nub = S.toList . S.fromList And i can't think of any type which i can't write a Hashable instance, so this is extremely

Re: [Haskell-cafe] [database-devel] Announcing postgresql-libpq-0.8.2.3

2013-07-08 Thread Joey Adams
On Mon, Jul 8, 2013 at 9:03 PM, Leon Smith leon.p.sm...@gmail.com wrote: I just fixed a fairly serious performance problem with postgresql-libpq's binding to PQescapeStringConn; in was exhibiting a non-linear slowdown when more strings are escaped and retained. I'd like to point out a

Re: [Haskell-cafe] How to design an network client with user program.

2013-04-15 Thread Joey Adams
I've been struggling with a similar situation: a client and server that communicate with binary-encoded messages, sending heartbeats (dummy messages) every 30 seconds, and timing out the connection if no response is received in 3 minutes. The client sends data to the server, while also listening

Re: [Haskell-cafe] Simple way to do something like ArrowChoice.right on a Conduit? (version 1.0.0)

2013-03-08 Thread Joey Adams
On Wed, Mar 6, 2013 at 1:42 AM, Michael Snoyman mich...@snoyman.com wrote: I'm still not sure I follow this. In the example I linked to, the go function within breaker could arbitrarily modify the data before it gets passed on to the inner Conduit. So it seems like it should be possible to

Re: [Haskell-cafe] Library API design: functional objects VS type classes

2013-03-05 Thread Joey Adams
On Mon, Mar 4, 2013 at 5:50 PM, Rob Stewart robstewar...@gmail.com wrote: ... - import Control.Concurrent -- API approach 1: Using type classes class FooC a where mkFooC :: IO a readFooC :: a - IO Int incrFooC :: a - IO () I recommend taking 'mkFooC' out of the typeclass. It

Re: [Haskell-cafe] Simple way to do something like ArrowChoice.right on a Conduit? (version 1.0.0)

2013-03-05 Thread Joey Adams
On Tue, Mar 5, 2013 at 9:24 AM, Michael Snoyman mich...@snoyman.com wrote: ... I'm not sure if I entirely understand your use case, but in general it should be possible to have multiple Conduits running one after the other. Here's an example of restarting an accumulator after every multiple

Re: [Haskell-cafe] Simple way to do something like ArrowChoice.right on a Conduit? (version 1.0.0)

2013-03-04 Thread Joey Adams
On Sun, Mar 3, 2013 at 10:24 PM, Joey Adams joeyadams3.14...@gmail.comwrote: ... Here's a possible API for a resumable Conduit: newtype ResumableConduit i m o = -- hidden -- newResumableConduit :: Monad m = Conduit i m o - ResumableConduit i m o -- | Feed the 'Source' through

Re: [Haskell-cafe] Simple way to do something like ArrowChoice.right on a Conduit? (version 1.0.0)

2013-03-03 Thread Joey Adams
Thanks for the response. I spent some time thinking about leftovers and understand the Category issue now. Thanks for clearing that up. While trying to work conduits into a program I'm working on, I find myself wanting something more powerful: a resumable Conduit. For example, consider

Re: [Haskell-cafe] Simple way to do something like ArrowChoice.right on a Conduit? (version 1.0.0)

2013-03-01 Thread Joey Adams
On Thu, Feb 28, 2013 at 9:18 PM, Joey Adams joeyadams3.14...@gmail.comwrote: Can I transform a conduit so some values are passed through unchanged, but others go through the conduit? For example: right :: Conduit i m o - Conduit (Either x i) m (Either x o) Actually, I didn't need

Re: [Haskell-cafe] Help: Main: thread blocked in MVar operation

2012-10-23 Thread Joey Adams
On Tue, Oct 23, 2012 at 5:03 PM, José A. Lopes jose.lo...@ist.utl.pt wrote: Hey everyone, I changed my code I now I get the following error message Main: thread blocked indefinitely in an MVar operation Before the change, I was using the State monad with runState. Then, I changed the

Re: [Haskell-cafe] One of the new buzz phrases is Event-Sourcing; is Haskell suitable for this?

2012-09-30 Thread Joey Adams
On Sat, Sep 29, 2012 at 8:46 PM, KC kc1...@gmail.com wrote: http://martinfowler.com/eaaDev/EventSourcing.html http://martinfowler.com/articles/lmax.html This notion of Capture all changes to an application state as a sequence of events sounds a lot like what John Carmack did in Quake 3 [1]:

Re: [Haskell-cafe] Platform Versioning Policy: upper bounds are not our friends

2012-08-16 Thread Joey Adams
On Wed, Aug 15, 2012 at 3:38 PM, Bryan O'Sullivan b...@serpentine.com wrote: I propose that the sense of the recommendation around upper bounds in the PVP be reversed: upper bounds should be specified only when there is a known problem with a new version of a depended-upon package. I, too,

Re: [Haskell-cafe] Data structure containing elements which are instances of the same type class

2012-08-07 Thread Joey Adams
On Tue, Aug 7, 2012 at 2:03 PM, Daniel Trstenjak daniel.trsten...@gmail.com wrote: Data structure containing elements which are instances of the same type class Are you looking for existential quantification [1]? data SomeFoo = forall a. Foo a = a [1]:

[Haskell-cafe] ANNOUNCE: system-time-monotonic-0.1

2012-08-06 Thread Joey Adams
system-time-monotonic [1] provides access to the system's monotonic clock. Usage looks like this: * Use 'newClock' to create a new monotonic clock * Use 'clockGetTime' to see how much time has elapsed since the clock was created. This package currently supports Linux and Windows. It might

[Haskell-cafe] ANN: stm-sbchan-0.1 - STM channel with maximum total size of items

2012-07-31 Thread Joey Adams
This package provides a bounded channel type for STM. TBChan (in stm-chans) and TBQueue (introduced in stm 2.4) are bounded channels that limit the number of items in the channel. SBChan, on the other hand, limits the total size of items in the channel, where size is defined by providing an

Re: [Haskell-cafe] Logging pure code

2012-07-29 Thread Joey Adams
On Fri, Jul 27, 2012 at 9:52 AM, Marco Túlio Gontijo e Silva marcotmar...@gmail.com wrote: I thought that the only thing I needed to take care while using unsafePerformIO was knowing that the time of execution is undetermined and that it could even run more than once. This is not a problem for

[Haskell-cafe] A useful function for forking a thread, but letting the parent do setup first

2012-07-18 Thread Joey Adams
Here's a useful little function: -- | Fork a thread, but wait for the main thread to perform a setup action -- using the child's 'ThreadID' before beginning work in the child thread. forkSetup :: (ThreadId - IO (Maybe a, r)) -- ^ Setup action to be called before the

Re: [Haskell-cafe] strange hangs with -threaded runtime

2012-07-13 Thread Joey Adams
On Fri, Jul 13, 2012 at 2:26 PM, Joey Hess j...@kitenet.net wrote: Are there any common gotchas with converting to the threaded runtime that might provide a hint to what's wrong? My code does not currently use Control.Concurrent or threads, although it does use some libraries like MissingH

Re: [Haskell-cafe] [Haskell] ANNOUNCE: control-monad-loop 0.1

2012-07-09 Thread Joey Adams
On Mon, Jul 9, 2012 at 8:28 AM, Roman Cheplyaka r...@ro-che.info wrote: Very nice! Here's a patch to generalize foreach to any Foldable: https://github.com/joeyadams/haskell-control-monad-loop/pull/1 Thanks for the patch! I merged it, but I plan to wait a little while before uploading

Re: [Haskell-cafe] Linking against Sqlite3 on Windows problem

2012-07-09 Thread Joey Adams
On Mon, Jul 9, 2012 at 3:56 AM, Eugene Dzhurinsky jdeve...@gmail.com wrote: Hi all! I created simple application, which uses sqlite3 as it's datastore back-end. I faced no problems when building and running it on Linux, but after I tried to build it on Windows, I see weird linking error: You

[Haskell-cafe] ANNOUNCE: control-monad-loop 0.1

2012-07-08 Thread Joey Adams
This package provides imperative-style loops supporting continue and break. For example: import Control.Monad import Control.Monad.IO.Class import Control.Monad.Trans.Loop import Control.Monad.Trans.Class main :: IO () main = foreach [0..] $ \i - foreach

Re: [Haskell-cafe] Threads and hGetLine

2012-04-28 Thread Joey Adams
On Sat, Apr 28, 2012 at 2:23 PM, H. M. h._h._...@hotmail.com wrote: There are two threads, one which is waits on input via hGetLine and another, which should terminate this thread or close this handle. hClose as well as killThread doesn't seem to work, caused by the fact, that the thread

Re: [Haskell-cafe] Looking for an heap-like data structure allowing efficient update

2012-03-04 Thread Joey Adams
On Sun, Mar 4, 2012 at 1:27 PM, Arnaud Bailly arnaud.oq...@gmail.com wrote: Hello Cafe, I am looking for a data structure that would have the following informal properties:  - allow efficient retrieval of minimum element for some ordering relation on a computed property of the elements  -

Re: [Haskell-cafe] Question about concurrency, threads and GC

2012-03-02 Thread Joey Adams
On Fri, Mar 2, 2012 at 3:04 PM, Alexander V Vershilov alexander.vershi...@gmail.com wrote: Hello, Paul. It seems you should not use 3 threads, but run in a data-driven behaviour with one thread per client. I don't think this will work for Paul's situation. He needs to be able to send

Re: [Haskell-cafe] Question about concurrency, threads and GC

2012-03-02 Thread Joey Adams
On Fri, Mar 2, 2012 at 7:34 PM, Joey Adams joeyadams3.14...@gmail.com wrote: I'll try to put together a simple chat server example, like the one I wrote for stm-channelize. Here it is: https://github.com/joeyadams/haskell-chat-server-example See, in particular, the serveLoop function

Re: [Haskell-cafe] ANN: network-socket-options 0.1

2012-02-23 Thread Joey Adams
On Wed, Feb 22, 2012 at 10:23 PM, Johan Tibell johan.tib...@gmail.com wrote: But the network package doesn't try to let you work with raw file descriptors elsewhere (e.g. send and recv.) I'm not saying that functions on Fds aren't useful, they are, just that the network package is the wrong

Re: [Haskell-cafe] ANN: network-socket-options 0.1

2012-02-22 Thread Joey Adams
On Wed, Feb 22, 2012 at 5:56 AM, L Corbijn aspergesoe...@gmail.com wrote: On Wed, Feb 22, 2012 at 5:58 AM, Joey Adams joeyadams3.14...@gmail.com wrote: I released network-socket-options 0.2, adding setSocketTimeouts and setHandleTimeouts.  I'll post an announcement in a separate thread once

Re: [Haskell-cafe] ANN: network-socket-options 0.1

2012-02-22 Thread Joey Adams
Thanks for the review! On Wed, Feb 22, 2012 at 11:15 AM, Johan Tibell johan.tib...@gmail.com wrote: The API looks fine except: HasSocket - I don't think we want to abstract over sockets here, as we don't do so in the rest of the module. I know it's a bit ugly, but not having it makes it hard

Re: [Haskell-cafe] ANN: network-socket-options 0.1

2012-02-21 Thread Joey Adams
On Tue, Feb 21, 2012 at 7:36 PM, Conrad Parker con...@metadecks.org wrote: awesome! I've prepared some patches for network to add this module and its tests, in this branch: https://github.com/kfish/network/tree/options Cool, thanks! I didn't modify any other modules, perhaps

Re: [Haskell-cafe] ANN: network-socket-options 0.1

2012-02-21 Thread Joey Adams
I released network-socket-options 0.2, adding setSocketTimeouts and setHandleTimeouts. I'll post an announcement in a separate thread once the Haddock documentation is generated. -Joey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] ANN: network-socket-options 0.1

2012-02-20 Thread Joey Adams
with network-bytestring. -Joey Adams ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] How to make asynchronous I/O composable and safe?

2012-01-17 Thread Joey Adams
On Tue, Jan 17, 2012 at 3:20 PM, David Barbour dmbarb...@gmail.com wrote: I'd say use of asynchronous exceptions should be a last resort. ... I agree. However, network libraries in Haskell (e.g. Handle, Network.TLS) generally don't provide the primitives needed to do that on the receiving end.

Re: [Haskell-cafe] How to make asynchronous I/O composable and safe?

2012-01-17 Thread Joey Adams
I uploaded a package that creates an STM layer over a network connection: http://hackage.haskell.org/package/stm-channelize I haven't used it in anger yet, but I hope it's a step in the right direction. I included a sample chat client and server. The client is pretty cute: main =

Re: [Haskell-cafe] How to make asynchronous I/O composable and safe?

2012-01-14 Thread Joey Adams
On Sat, Jan 14, 2012 at 1:29 AM, Bardur Arantsson s...@scientician.net wrote: So, the API becomes something like:   runSocketServer :: ((Chan a, Chan b) - IO ()) - ... - IO () where the first parameter contains the client logic and A is the type of the messages from the client and B is the

[Haskell-cafe] How to make asynchronous I/O composable and safe?

2012-01-13 Thread Joey Adams
I'm not happy with asynchronous I/O in Haskell.  It's hard to reason about, and doesn't compose well.  At least in my code. I'm currently trying to build a networking layer for my application using Network.TLS.  Here is a rather minimalist API:    newtype Connection = Connection (TLSCtx Handle)

Re: [Haskell-cafe] STM: nested atomically error

2012-01-12 Thread Joey Adams
On Thu, Jan 12, 2012 at 7:48 AM, Johan Brinch brin...@gmail.com wrote: Hi all, I'm seeing the Control.Concurrent.STM.atomically was nested error, but I just can't figure out what's happening. I'm not using any unsafe IO (only for debug printing), and the test program is only running one

Re: [Haskell-cafe] ANN: Monad.Reader Issue 19

2011-10-31 Thread Joey Adams
On Wed, Oct 26, 2011 at 4:24 PM, Bas van Dijk v.dijk@gmail.com wrote: I have one question regarding your use of atomicModifyIORef:  x - atomicModifyIORef ref (\_ - (tmstr, ()))  x `seq` return () Can't you write that as just: writeIORef ref tmstr? If you're not using the previous value