Re: [Haskell-cafe] How to use "bracket" properly ?

2009-10-18 Thread zaxis
The original code is: winSSQ count noRed noBlue = do let yesRed = [1..33] \\ noRed let yesBlue = [1..16] \\ noBlue bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1) It works very well. However, as i am used to C style so i want convert it

Re: [Haskell-cafe] How to use "bracket" properly ?

2009-10-18 Thread Thomas DuBuisson
> thanks for your quick answer. But I think he actually answered your question. I.e. try it with this extra 'do' statement: winSSQ count noRed noBlue = do { do    let yesRed =  [1..33] \\ noRed;    let yesBlue = [1..16] \\ noBlue;    bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 ->

Re: [Haskell-cafe] How to use "bracket" properly ?

2009-10-18 Thread zaxis
thanks for your quick answer. But winSSQ count noRed noBlue = do { let yesRed = [1..33] \\ noRed; let yesBlue = [1..16] \\ noBlue; bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1); } will report: parse error on input `let' Daniel Peebl

Re: [Haskell-cafe] How to use "bracket" properly ?

2009-10-18 Thread Daniel Peebles
They're "in" different Monads. The first one does x <- [...], which means that you're operating in the list Monad instance, and bracket operates in the IO Monad. The second one uses let x = [...] which doesn't have any effect on what Monad you're in, so the whole thing can be in IO. Note that when

[Haskell-cafe] How to use "bracket" properly ?

2009-10-18 Thread zaxis
winSSQ count noRed noBlue = do { yesRed <- [1..33] \\ noRed; yesBlue <- [1..16] \\ noBlue; bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ count yesRed yesBlue hd1); return () } will report: Couldn't match expected type `IO ()' against inferred type `[()]'

Re: [Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-18 Thread wren ng thornton
Will Ness wrote: Luke Palmer gmail.com> writes: Or you could use the "subtract" function. >>> map (subtract 2) [3,4,5] [1,2,3] I don't want to. I don't think syntax sugar is worth it in this case. I do. Operators are great because they make our intent visible, immediately apparent.

[Haskell-cafe] Problems with Haskell

2009-10-18 Thread Philippos Apolinarius
Before anything else, I want to point out that I have no intention to confront your community, or denigrate Haskell. A few days ago I answered an email from a Clean programmer on something related to Clean. He was worried that Clean team could give up its good work, and Clean could disappear; th

[Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-18 Thread Will Ness
Luke Palmer gmail.com> writes: > > Or you could use the "subtract" function. > > >>> map (subtract 2) [3,4,5] > [1,2,3] I don't want to. > > I don't think syntax sugar is worth it in this case. I do. Operators are great because they make our intent visible, immediately apparent. Long

Re: [Haskell-cafe] Error handling package

2009-10-18 Thread Michael Snoyman
(Sorry, accidently took off cafe.) On Mon, Oct 19, 2009 at 12:44 AM, Henning Thielemann < lemm...@henning-thielemann.de> wrote: > > On Mon, 19 Oct 2009, Michael Snoyman wrote: > > Does the explicit-exception package provide what you need? >> >> http://hackage.haskell.org/package/explicit-excepti

Re: [Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-18 Thread Luke Palmer
On Sun, Oct 18, 2009 at 4:47 PM, Will Ness wrote: > Gregory Propf yahoo.com> writes: > >> >> >> I actually meant it as sort of a joke but maybe it's not after all. > > Seriously though, using anything non-ASCII in source code is a bad idea, > because there are lots of fonts and editors in the wor

[Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-18 Thread Will Ness
Gregory Propf yahoo.com> writes: > > > I actually meant it as sort of a joke but maybe it's not after all. Seriously though, using anything non-ASCII in source code is a bad idea, because there are lots of fonts and editors in the world. It seems natural to me to have (`-`2) stand for (fli

Re: [Haskell-cafe] Error handling package

2009-10-18 Thread Henning Thielemann
On Sun, 18 Oct 2009, Michael Snoyman wrote: While working on the next release of data-object, I wanted to represent some operations that might fail. The typical candidates were: 1) Maybe 2) Either 3) Monad Monad is always iffy because of the often times poorly defined fail. Maybe doesn't pr

[Haskell-cafe] Error handling package

2009-10-18 Thread Michael Snoyman
While working on the next release of data-object, I wanted to represent some operations that might fail. The typical candidates were: 1) Maybe 2) Either 3) Monad Monad is always iffy because of the often times poorly defined fail. Maybe doesn't provide any means of reporting what the problem was.

Re: [Haskell-cafe] Lecture Notes Advanced Functional programming available

2009-10-18 Thread Warren Henning
$83 and "3-4 weeks" for a 300 page book? Oy vey. Warren On Fri, Oct 16, 2009 at 7:24 AM, S. Doaitse Swierstra wrote: > I am happy to announce that the rworked lecture notes for the 6th Advance > Functional programming summer school have become available. _

Re: [Haskell-cafe] Too much strictness in binary-0.5.0.2

2009-10-18 Thread Duncan Coutts
On Sun, 2009-10-18 at 19:53 +0400, Alexey Khudyakov wrote: > > Yes. We decided that having the Get monad as a lazy state monad just > > doesn't make sense. It makes this one use case work, but causes more > > problems generally. Certainly we need to be able to do lazy binary > > deserialisation too

[Haskell-cafe] Re: Merging modules (again)

2009-10-18 Thread pat browne
Hi, I have tried qualified imports, synonyms and newtypes but still I could not implement the merging task (previously posted). This is probably because I have little knowledge of Haskell *or* the task is not really suited to Haskell (more of a specification task than a programming task). My main

Re: [Haskell-cafe] x -> String

2009-10-18 Thread Matt Morrow
On 10/17/09, Andrew Coppin wrote: > Derek Elkins wrote: >> See vacuum: http://hackage.haskell.org/package/vacuum >> > Could be useful... Thanks! > As Derek mentioned, vacuum would be perfect for this: - import Data.Wo

Re: [Haskell-cafe] Too much strictness in binary-0.5.0.2

2009-10-18 Thread Alexey Khudyakov
> Yes. We decided that having the Get monad as a lazy state monad just > doesn't make sense. It makes this one use case work, but causes more > problems generally. Certainly we need to be able to do lazy binary > deserialisation too, but our feeling is that it should be more explicit > and integrat

Re: [Haskell-cafe] Documentation (was: ANN: text 0.5, a major revision of the Unicode text library)

2009-10-18 Thread Sean Leather
Hi John, On Sun, Oct 11, 2009 at 14:58, John Lato wrote: > For anyone writing introductions to generic programming, take this as > a plea from Haskellers everywhere. If one of the RWH authors can't > understand how to make use of these techniques, what hope do the rest > of us have? > I would l

Re: [Haskell-cafe] Too much strictness in binary-0.5.0.2

2009-10-18 Thread Duncan Coutts
On Sat, 2009-09-19 at 00:36 +0400, Khudyakov Alexey wrote: > Hello > > I run into problems with new binary package. Following function reads a list > of elements one by one until end of stream. List is very long (won't fit into > memory). Sorry for the late reply. > In binary-0.5.0.1 and earli

Re: [Haskell-cafe] Lecture Notes Advanced Functional programming available

2009-10-18 Thread Sean Leather
> I am happy to announce that the rworked lecture notes for the 6th Advance > Functional programming summer school have become available. > Thanks, Doaitse. >• Johan Jeuring (Utrecht University, NL): Libraries for Generic > Programming in Haskell An extended version of this article is

Re: [Haskell-cafe] Happstack + network package issue on the Mac

2009-10-18 Thread Sean Leather
On Sat, Oct 10, 2009 at 15:13, Duncan Coutts wrote: > From what Gregory and Anton have said, it sounds like the SockAddr6, > HostAddress6 constructors should always be available, but that using > them with the socket functions should fail at runtime on platforms with > no IPv6 support, or when IPv

[Haskell-cafe] \Statically checked binomail heaps?

2009-10-18 Thread Maciej Kotowicz
Hi, first of all this post is literate haskell I'm trying to implement a binomial heaps from okaski's book [1] but as most it's possible to be statically checked for correctness of definition. Remark that binomial heap is list of binomial trees in increasing order of rank and binomial heap of rank