Re: [Haskell-cafe] Enumerators, Enumeratees and Iterators

2011-06-28 Thread Dmitry Olshansky
Hi, for the first question you can look at combinators in Data.Iteratee.ListLikehttp://hackage.haskell.org/packages/archive/iteratee/0.8.5.0/doc/html/Data-Iteratee-ListLike.html for iteratee package or

[Haskell-cafe] Cleaner way to write code and handle errors?

2011-06-28 Thread John Ky
Hi all, I'm practising my Haskell by writing a simple TCP echo server and finding that getting my program control to be succinct is rather tricky. In particular, I have return () everywhere, my error handling is verbose and I'm not entirely sure my recursion is the cleanest way syntactically to

Re: [Haskell-cafe] Cleaner way to write code and handle errors?

2011-06-28 Thread Ivan Lazar Miljenovic
On 28 June 2011 18:08, John Ky newho...@gmail.com wrote: Hi all, I'm practising my Haskell by writing a simple TCP echo server and finding that getting my program control to be succinct is rather tricky.  In particular, I have return () everywhere, my error handling is verbose and I'm not

Re: [Haskell-cafe] Data Flow Programming in FP

2011-06-28 Thread Richard Senington
On 20/06/11 15:45, Richard Senington wrote: Hi all, I have recently become interested in Dataflow programming and how it related to functional languages. I am wondering if the community has any advice on reading matter or other directions to look at. So far I have been looking through the

Re: [Haskell-cafe] Cleaner way to write code and handle errors?

2011-06-28 Thread Erik de Castro Lopo
Ivan Lazar Miljenovic wrote: I don't think you need all those return () everywhere... And at the end, why do you do line - getLine when you don't use the result? The hlint program would have flagged both of those and possibly others. See: http://community.haskell.org/~ndm/hlint/ Erik --

Re: [Haskell-cafe] Enumerators, Enumeratees and Iterators

2011-06-28 Thread Ertugrul Soeylemez
Sævar Berg s.b.saevars...@gmail.com wrote: The first question is, I think, to be solved with enumeratees but I can't really grok how. Let's say I have an iteratee that consumes all input. Is it possible to implement an enumeratee or something else to stick between the enumerator and the

[Haskell-cafe] Possible bug in GHC 7.0.3

2011-06-28 Thread Alberto G. Corona
I have an 'impossible' happened error. The code may look a little bit convoluted but it is part of my real code.: - begin of code-- {-# LANGUAGE FlexibleInstances, UndecidableInstances , MultiParamTypeClasses #-} class Serializable a b class

Re: [Haskell-cafe] Cleaner way to write code and handle errors?

2011-06-28 Thread John Ky
Hi Eric, Ivan, On 28 June 2011 18:32, Erik de Castro Lopo mle...@mega-nerd.com wrote: The hlint program would have flagged both of those and possibly others. See: Cool! It didn't flag either for me, but it recommended replacing ++ (show port)with ++ show port, if then else with unless,

Re: [Haskell-cafe] Cleaner way to write code and handle errors?

2011-06-28 Thread Jonas Almström Duregård
There is the void function in Control.Monad: http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Monad.html#v:void Instead of using return () you can just use void processLine. Also some people like to use the either function instead of matching on Left/Right. In this case

Re: [Haskell-cafe] Cleaner way to write code and handle errors?

2011-06-28 Thread John Ky
Thanks Jonas, I feel much better already: import Control.Concurrent import Control.Exception import Control.Monad import Network import System.IO import System.IO.Error (isEOFError) main = withSocketsDo $ do sListen - listenOn (PortNumber 8000) putStrLn Listening on Port 8000 forkIO $

Re: [Haskell-cafe] What is a simple pattern binding?

2011-06-28 Thread Simon Marlow
On 26/06/2011 09:31, Paterson, Ross wrote: If this is the case, then multiple sentences in the 2010 report don't make sense, though the way in which they don't make sense sort of depends on what simple pattern binding means. Indeed, the Report has two problems: Sections 4.4.3.2 and 4.5.5 have

Re: [Haskell-cafe] Enumerators, Enumeratees and Iterators

2011-06-28 Thread Dmitry Olshansky
If I've understood it correctly, concurrent is similar to functions discussed here: http://www.haskell.org/pipermail/haskell-cafe/2011-April/091474.html and here http://www.haskell.org/pipermail/haskell-cafe/2011-January/088319.html 2011/6/28 Ertugrul Soeylemez e...@ertes.de Sævar Berg

[Haskell-cafe] Exclusive mode in openFile

2011-06-28 Thread Gracjan Polak
Hi all, It seems I'm not allowed to open same file both for writing and for reading: Prelude System.IO f_out - openFile mylog.log AppendMode Prelude System.IO f_in - openFile mylog.log ReadMode *** Exception: mylog.log: openFile: resource busy (file is locked) Usage scenario: I use hslogger

Re: [Haskell-cafe] Installation Failed: Haskell Platform 2011.2.0.1-i386 for OS X

2011-06-28 Thread Jason Dagit
On Mon, Jun 27, 2011 at 10:33 AM, John Velman vel...@cox.net wrote: I'm running OS X 10.6.7, XCode 3.2.5.  When  I try to install The Haskell Platform 2011.2.0.1 for Mac OS X 10.6 (Snow Leopard)  it goes all the way through to running package scripts, then says installation failed I did two

Re: [Haskell-cafe] Possible bug in GHC 7.0.3

2011-06-28 Thread Jason Dagit
On Tue, Jun 28, 2011 at 3:43 AM, Alberto G. Corona agocor...@gmail.com wrote: I have an 'impossible' happened error. The code may look a little bit convoluted but it is part of my real code.: I don't know why it's crashing, but did you already report it as a bug? If not, you definitely should.

Re: [Haskell-cafe] Exclusive mode in openFile

2011-06-28 Thread Max Bolingbroke
On 28 June 2011 17:50, Gracjan Polak gracjanpo...@gmail.com wrote: It seems I'm not allowed to open same file both for writing and for reading: This behaviour is part of the Haskell 98 specification (section 21.2.3, http://www.haskell.org/onlinereport/io.html): Implementations should enforce

Re: [Haskell-cafe] Possible bug in GHC 7.0.3

2011-06-28 Thread Alberto G. Corona
Reported: http://hackage.haskell.org/trac/ghc/ticket/5287 2011/6/28 Alberto G. Corona agocor...@gmail.com 2011/6/28 Jason Dagit dag...@gmail.com On Tue, Jun 28, 2011 at 3:43 AM, Alberto G. Corona agocor...@gmail.com wrote: I have an 'impossible' happened error. The code may look a

Re: [Haskell-cafe] Enumerators, Enumeratees and Iterators

2011-06-28 Thread Alexander Solla
On Mon, Jun 27, 2011 at 7:21 PM, Sævar Berg s.b.saevars...@gmail.comwrote: The first question is, I think, to be solved with enumeratees but I can't really grok how. Let's say I have an iteratee that consumes all input. Is it possible to implement an enumeratee or something else to stick

Re: [Haskell-cafe] Exclusive mode in openFile

2011-06-28 Thread Gracjan Polak
Max Bolingbroke batterseapower at hotmail.com writes: This behaviour is part of the Haskell 98 specification (section 21.2.3, http://www.haskell.org/onlinereport/io.html): Thanks for the explanation. Such sharing behavior should be mentioned in documentation:

Re: [Haskell-cafe] Exclusive mode in openFile

2011-06-28 Thread Brandon Allbery
On Tue, Jun 28, 2011 at 13:56, Gracjan Polak gracjanpo...@gmail.com wrote: What was the rationale behind such strict non-sharing policy? The obvious rationale is that it helps maintain the illusion of referential integrity within the process. (Outside is a lost cause, but operations on

Re: [Haskell-cafe] Installation Failed: Haskell Platform 2011.2.0.1-i386 for OS X

2011-06-28 Thread Tom Murphy
On 6/28/11, Jason Dagit dag...@gmail.com wrote: I'd try asking on StackOverflow. I think the people who know the answer might be watching there instead of here. Really? I had thought that everyone who was on SO was on here also. Tom ___

Re: [Haskell-cafe] Installation Failed: Haskell Platform 2011.2.0.1-i386 for OS X

2011-06-28 Thread Jason Dagit
On Tue, Jun 28, 2011 at 11:14 AM, Tom Murphy amin...@gmail.com wrote: On 6/28/11, Jason Dagit dag...@gmail.com wrote: I'd try asking on StackOverflow.  I think the people who know the answer might be watching there instead of here. Really? I had thought that everyone who was on SO was on

[Haskell-cafe] Problem building with Cabal + TH + Library with FFI to C++ via C Wrapper

2011-06-28 Thread Ozgun Ataman
Dear Cafe, I have recently run into a very annoying issue that I was not able to get around. I have a local package that makes use of the snappy compression library, which boasts bindings to C++ through a C wrapper. Everything compiles fine with ghc --make, but cabal install hits a wall when

Re: [Haskell-cafe] Exclusive mode in openFile

2011-06-28 Thread Max Bolingbroke
On 28 June 2011 18:56, Gracjan Polak gracjanpo...@gmail.com wrote: Anyway, where do I find an 'openFileShared' function? Packages unix/Win32 do not have obvious leads... Perhaps the functions in System.Posix.IO do what you want?

[Haskell-cafe] attoparsec and vectors

2011-06-28 Thread Eric Rasmussen
Hi everyone, I have a task that involves parsing a flat-file into a vector from the Data.Vector package. In the interest of keeping things simple, I first used Attoparsec.Text's version of many and then converted the resulting list to a vector: import qualified Data.Vector as V import

[Haskell-cafe] IterIO type restricted functions

2011-06-28 Thread John Ky
Hi all, From the IterIO tutorial: enumFile' is like enumFile above, but type restricted to data in the lazy ByteString format, which is more efficient than plain Strings. (enumFile supports multiple types, but in this example there is not enough information for Haskell to choose one of them, so

Re: [Haskell-cafe] Possible bug in GHC 7.0.3

2011-06-28 Thread Ryan Ingram
So this is definitely a GHC bug, but I think the problem is probably triggered by this line: instance Serializable a b = IResource a I don't think this is a valid instance declaration without a functional dependency on Serializable, as it's impossible to know which type 'b' to use in the

Re: [Haskell-cafe] attoparsec and vectors

2011-06-28 Thread Gregory Collins
On Tue, Jun 28, 2011 at 6:20 PM, Eric Rasmussen ericrasmus...@gmail.com wrote: It runs quickly, but I naively thought I could outperform it by reworking many to build a vector directly, instead of having to build a list first and then convert it to a vector: manyVec :: Alternative f = f a - f

Re: [Haskell-cafe] IterIO type restricted functions

2011-06-28 Thread dm-list-haskell-cafe
At Wed, 29 Jun 2011 10:11:26 +1000, John Ky wrote: [1 multipart/alternative (7bit)] [1.1 text/plain; ISO-8859-1 (7bit)] Hi all, From the IterIO tutorial: enumFile' is like enumFile above, but type restricted to data in the lazy ByteString format, which is more efficient