Re: [Haskell-cafe] Right tree structure for complicated problem

2012-01-22 Thread Pierre Penninckx
Not exactly: The aim is not to know which path must the water take to the least time. The fact is, the water can only take one path, due to the circuit configuration, from the source to the exit, so there is no choice for the water. It's not a graph with multiple paths, it's a tree with leafs as

[Haskell-cafe] Data newtype differences. Today: strictness

2012-01-22 Thread Yves Parès
Hello, I had for long thought that data and newtype were equivalent, but then I spotted some differences when it comes to strictness. Those can be summed up as: data Test = Test Int newtype TestN = TestN Int pm (Test _) = 12 -- Strict (pm undefined = undefined) pm2 t = t `seq` 12 -- Strict

Re: [Haskell-cafe] Data newtype differences. Today: strictness

2012-01-22 Thread Roman Cheplyaka
* Yves Parès yves.pa...@gmail.com [2012-01-22 11:32:30+0100] These make me think that pattern matching against a newtype is always lazy (irrefutable). Am I right? Yes. Is there some litterature expliciting in a less empiric way than I did the differences like this between data and newtype?

Re: [Haskell-cafe] Compiling dph package with ghc-7.4.0.20111219

2012-01-22 Thread Atsuro Hoshino
I don't know so much about ghc-7.4, but if loading dph codes in ghci is the main matter here, below might help: http://warmfuzzything.posterous.com/loading-dph-codes-in-ghci Best, -- Atsuro Hoshino On Sun, Jan 22, 2012 at 2:58 AM, Brandon Allbery allber...@gmail.com wrote: On Sat, Jan 21,

Re: [Haskell-cafe] Data newtype differences. Today: strictness

2012-01-22 Thread Yitzchak Gale
Yves Parès wrote: Is there some litterature expliciting in a less empiric way than I did the differences like this between data and newtype? I've never come against such documentation through all my learning of Haskell, yet I think it's an important point. Roman Cheplyaka wrote: See the

Re: [Haskell-cafe] Data newtype differences. Today: strictness

2012-01-22 Thread Yves Parès
Thanks, that's clearer to me now. It confirmed my thoughts: Matching the pattern con pat against a value, where con is a constructor defined by newtype, depends on the value: - If the value is of the form con v, then pat is matched against v. - If the value is ⊥, then pat is matched against ⊥.

Re: [Haskell-cafe] Data newtype differences. Today: strictness

2012-01-22 Thread Yves Parès
Big sum up of everything: If TestN is a newtype constructor, then 'TestN undefined' and 'undefined' are exactly the same thing. 2012/1/22 Yitzchak Gale g...@sefer.org Yves Parès wrote: Is there some litterature expliciting in a less empiric way than I did the differences like this

Re: [Haskell-cafe] Data newtype differences. Today: strictness

2012-01-22 Thread Roman Cheplyaka
* Yves Parès yves.pa...@gmail.com [2012-01-22 15:23:51+0100] Big sum up of everything: If TestN is a newtype constructor, then 'TestN undefined' and 'undefined' are exactly the same thing. To be precise, the former is a type-restricted version of the latter. -- Roman I. Cheplyaka ::

Re: [Haskell-cafe] Monads, do and strictness

2012-01-22 Thread Sebastian Fischer
On Sat, Jan 21, 2012 at 8:09 PM, David Barbour dmbarb...@gmail.com wrote: In any case, I think the monad identity concept messed up. The property:   return x = f = f x Logically only has meaning when `=` applies to values in the domain. `undefined` is not a value in the domain. We can

Re: [Haskell-cafe] Monads, do and strictness

2012-01-22 Thread David Barbour
observably different from `undefined` If we understand `undefined` as meaning a computation that never ends, then you cannot ever observe whether one `undefined` is or is not equivalent to another. In strict languages, this is especially obvious. In any case, I don't accept a concept of

Re: [Haskell-cafe] Monads, do and strictness

2012-01-22 Thread MigMit
Отправлено с iPad 22.01.2012, в 20:25, David Barbour dmbarb...@gmail.com написал(а): Attempting to shoehorn `undefined` into your reasoning about domain algebras and models and monads is simply a mistake. No. Using the complete semantics — which includes bottoms aka undefined — is a

Re: [Haskell-cafe] Monads, do and strictness

2012-01-22 Thread David Barbour
2012/1/22 MigMit miguelim...@yandex.ru Отправлено с iPad 22.01.2012, в 20:25, David Barbour dmbarb...@gmail.com написал(а): Attempting to shoehorn `undefined` into your reasoning about domain algebras and models and monads is simply a mistake. No. Using the complete semantics — which

Re: [Haskell-cafe] where to put general-purpose utility functions

2012-01-22 Thread David Fox
I try to create a workflow for this sort of thing. I create a package with a name like set-extra, with one module Data.Set.Extra and an alternative Data.Set module that exports both the old Data.Set and the symbols in Data.Set.Extra. Then I email the maintainers of the Containers package with a

Re: [Haskell-cafe] Contributing to http-conduit

2012-01-22 Thread Myles C. Maxfield
Replies are inline. Thanks for the quick and thoughtful response! On Sat, Jan 21, 2012 at 8:56 AM, Michael Snoyman mich...@snoyman.comwrote: Hi Myles, These sound like two solid features, and I'd be happy to merge in code to support it. Some comments below. On Sat, Jan 21, 2012 at 8:38 AM,

Re: [Haskell-cafe] Compiling dph package with ghc-7.4.0.20111219

2012-01-22 Thread mukesh tiwari
Thank you. It helped me lot. Regards Mukesh Tiwari On Sun, Jan 22, 2012 at 7:14 PM, Atsuro Hoshino hoshinoats...@gmail.comwrote: I don't know so much about ghc-7.4, but if loading dph codes in ghci is the main matter here, below might help:

[Haskell-cafe] [C][enums][newbie] What is natural Haskell representation of such enum?

2012-01-22 Thread Данило Глинський
What is natural Haskell representation of such enum? enum TypeMask { UNIT, GAMEOBJECT, CREATURE_OR_GAMEOBJECT = UNIT | GAMEOBJECT }; More sophisticated question is: and what data structures must be used when converting this naturally one to Haskell? // 1-byte flaged enum enum TypeMask

Re: [Haskell-cafe] [C][enums][newbie] What is natural Haskell representation of such enum?

2012-01-22 Thread David Barbour
Performing bit-mask operations is possible via the Data.Bits operations (on elements of type Word8 or Word16, etc.). But I must say, it doesn't seem very `natural` in Haskell, nor even in other languages. It crosses lines, binding abstraction to representation in order to improve efficiency. The

Re: [Haskell-cafe] [C][enums][newbie] What is natural Haskell representation of such enum?

2012-01-22 Thread Erik de Castro Lopo
Данило Глинський wrote: What is natural Haskell representation of such enum? enum TypeMask { UNIT, GAMEOBJECT, CREATURE_OR_GAMEOBJECT = UNIT | GAMEOBJECT }; data ObjectType = Unit | GameObject creatureOrGameObject :: ObjectType - Bool creatureOrGameObject Unit = True

Re: [Haskell-cafe] [C][enums][newbie] What is natural Haskell representation of such enum?

2012-01-22 Thread Yves Parès
I may be curious to see how you intend to use such enum... It is very C-wise, I'm not sure it will be very handy, but I need some context. 2012/1/22 Данило Глинський abcz2.upr...@gmail.com What is natural Haskell representation of such enum? enum TypeMask { UNIT, GAMEOBJECT,

Re: [Haskell-cafe] Compiling dph package with ghc-7.4.0.20111219

2012-01-22 Thread Ben Lippmeier
On 21/01/2012, at 22:47 , mukesh tiwari wrote: Hello all I have installed ghc-7.4.0.20111219 and this announcement says that The release candidate accidentally includes the random, primitive, vector and dph libraries. The final release will not include them. I tried to compile a

Re: [Haskell-cafe] Idris

2012-01-22 Thread John Lask
On 21/01/2012 5:45 AM, Ryan Ingram wrote: Has anyone played with Idris (http://idris-lang.org/) at all? It looks interesting, and I'd love to play with it, but unfortunately I only have windows machines up and running at the moment and the documentation seems to imply it only builds on unixy

Re: [Haskell-cafe] Contributing to http-conduit

2012-01-22 Thread Michael Snoyman
On Sun, Jan 22, 2012 at 11:07 PM, Myles C. Maxfield myles.maxfi...@gmail.com wrote: Replies are inline. Thanks for the quick and thoughtful response! On Sat, Jan 21, 2012 at 8:56 AM, Michael Snoyman mich...@snoyman.com wrote: Hi Myles, These sound like two solid features, and I'd be happy

Re: [Haskell-cafe] Contributing to http-conduit

2012-01-22 Thread Myles C. Maxfield
1. Oops - I overlooked the fact that the redirectCount attribute of a Request is exported (it isn't listed on the documentationhttp://hackage.haskell.org/packages/archive/http-conduit/1.2.0/doc/html/Network-HTTP-Conduit.html probably because the constructor itself isn't exported. This seems like a

Re: [Haskell-cafe] Contributing to http-conduit

2012-01-22 Thread Michael Snoyman
On Mon, Jan 23, 2012 at 8:31 AM, Myles C. Maxfield myles.maxfi...@gmail.com wrote: 1. Oops - I overlooked the fact that the redirectCount attribute of a Request is exported (it isn't listed on the documentation probably because the constructor itself isn't exported. This seems like a flaw in

Re: [Haskell-cafe] Contributing to http-conduit

2012-01-22 Thread Aristid Breitkreuz
Just make sure Cookie handling can be disabled completely. Aristid Am 23.01.2012 07:44 schrieb Michael Snoyman mich...@snoyman.com: On Mon, Jan 23, 2012 at 8:31 AM, Myles C. Maxfield myles.maxfi...@gmail.com wrote: 1. Oops - I overlooked the fact that the redirectCount attribute of a

[Haskell-cafe] Can't install hspec

2012-01-22 Thread Erik de Castro Lopo
Hi all, I'm trying to cabal install hspec and I get the following: Resolving dependencies... /tmp/hspec-0.9.04062/hspec-0.9.0/Setup.lhs:2:10: Could not find module `System' It is a member of the hidden package `haskell98-2.0.0.0'. Use -v to see a list of the

Re: [Haskell-cafe] Contributing to http-conduit

2012-01-22 Thread Myles C. Maxfield
Alright, that sounds good to me. I'll get started on it (the IORef idea). Thanks for the insight! --Myles On Sun, Jan 22, 2012 at 10:42 PM, Michael Snoyman mich...@snoyman.comwrote: On Mon, Jan 23, 2012 at 8:31 AM, Myles C. Maxfield myles.maxfi...@gmail.com wrote: 1. Oops - I overlooked the

Re: [Haskell-cafe] Contributing to http-conduit

2012-01-22 Thread Michael Snoyman
The only times cookies would be used would be: 1. If you explicitly use it. 2. If you have redirects turned on, and a page that redirects you also sets a cookie. I would think that we would want (2) to be on regardless of user setting, do you disagree? Michael On Mon, Jan 23, 2012 at 8:46 AM,

Re: [Haskell-cafe] Contributing to http-conduit

2012-01-22 Thread Myles C. Maxfield
I'm a little confused as to what you mean by 'cookie handling'. Do you mean cookies being set inside redirects for future requests inside the same redirect chain, or users being able to supply cookies to the first HTTP request and pull them out of the last HTTP response? Clearly, making the

Re: [Haskell-cafe] Contributing to http-conduit

2012-01-22 Thread Aristid Breitkreuz
Indeed, I disagree on 2. Sometimes there is an API and cookies are just not part of it (and redirects are). Aristid Am 23.01.2012 08:16 schrieb Michael Snoyman mich...@snoyman.com: The only times cookies would be used would be: 1. If you explicitly use it. 2. If you have redirects turned on,

Re: [Haskell-cafe] Contributing to http-conduit

2012-01-22 Thread Michael Snoyman
That's a violation of the spec. Having a server set a cookie and then not really mean it or something along those lines would be invalid. And having a server not set a cookie at all means having this feature would be irrelevant. On Mon, Jan 23, 2012 at 9:42 AM, Aristid Breitkreuz