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 ] > [1.1 ] > > 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 multip

Re: [Haskell-cafe] attoparsec and vectors

2011-06-28 Thread Gregory Collins
On Tue, Jun 28, 2011 at 6:20 PM, Eric Rasmussen 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 (V.Vector a) >

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 method

[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

[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 Data.Atto

Re: [Haskell-cafe] Exclusive mode in openFile

2011-06-28 Thread Max Bolingbroke
On 28 June 2011 18:56, Gracjan Polak 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? http://hackage.haskell.org/packages/archive/unix/2.4.2.0/doc/html/System-Posix-IO.ht

[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 Temp

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 wrote: > On 6/28/11, Jason Dagit 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. The operati

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 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 ___ Haskell-Cafe mailing

Re: [Haskell-cafe] Exclusive mode in openFile

2011-06-28 Thread Brandon Allbery
On Tue, Jun 28, 2011 at 13:56, Gracjan Polak 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 different file handles are ass

Re: [Haskell-cafe] Exclusive mode in openFile

2011-06-28 Thread Gracjan Polak
Max Bolingbroke 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: http://hackage.haskell.org/packages/archive/hask

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 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

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 > > 2011/6/28 Jason Dagit > >> On Tue, Jun 28, 2011 at 3:43 AM, Alberto G. Corona >> wrote: >> > I have an "'impossible' happened" error. >> > The code may look a little bit convoluted but it is part of my re

Re: [Haskell-cafe] Exclusive mode in openFile

2011-06-28 Thread Max Bolingbroke
On 28 June 2011 17:50, Gracjan Polak 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 as far as possible,

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 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. > Please repor

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 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 separ

[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 hsl

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 > Sævar Berg wrote: > > > The

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 hav

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] 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 yo

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 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, putStrLn (show x) with

[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 IRe

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

2011-06-28 Thread Ertugrul Soeylemez
Sævar Berg 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 iteratee to basically mo

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] 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 FR

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 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 entirely sure my

[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 g