Re: [Haskell-cafe] Binary constants in Haskell

2007-10-25 Thread Ketil Malde
Don Stewart [EMAIL PROTECTED] writes: Are there binary constants in Haskell, as we have, for instance, 0o232 for octal and 0xD29A for hexadecimal? No, though it is an interesting idea. Presumably it is less common since octal and hexadecimal are more compact and almost as easy to interpret

[Haskell-cafe] Re: Existential types (Was: Type vs TypeClass duality)

2007-10-25 Thread apfelmus
Dan Weston wrote: Thanks for the concise explanation. I do have one minor question though. -+- A more useful example is ∃a. Show a = a i.e. ∃a.(a - String, a) So, given a value (f,x) :: ∃a.(a - String, a), we can do f x :: String but that's pretty much all we can

[Haskell-cafe] Re: Existential types (Was: Type vs TypeClass duality)

2007-10-25 Thread apfelmus
Peter Hercek wrote: I do not see why forall can be lifted to the top of function arrows. I probably do not understand the notation at all. They all seem to be different to me. String - ∀a.a a function which takes strings a returns a value of all types together for any input string (so only

[Haskell-cafe] Haskell Paralellism

2007-10-25 Thread Dominik Luecke
Hello, I am trying to use the code rels list = let o1 = (map makeCompEntry) $ head $ splitList list o2 = (map makeCompEntry) $ head $ tail $ splitList list o3 = (map makeCompEntry) $ head $ tail $ tail $ splitList list in case (head $ tail $ tail $ tail $

Re: [Haskell-cafe] Haskell Paralellism

2007-10-25 Thread Alberto Ruiz
Hello Dominik, I have used something like this and it worked very well: import Control.Parallel.Strategies inParallel = parMap rwhnf id [a,b] = inParallel [f x, g y] I hope it helps, Alberto On Thursday 25 October 2007 11:36, Dominik Luecke wrote: Hello, I am trying to use the code

[Haskell-cafe] Re: Existential types (Was: Type vs TypeClass duality)

2007-10-25 Thread apfelmus
Alfonso Acosta wrote: This bit was specially helpful: So, how to compute a value b from an existential type ∃a.(a - a)? ... Could you give a specific example of computing existential types? Well, the word compute was probably not a good choice, I meant the following question: given a type

Re: [Haskell-cafe] Haskell Paralellism

2007-10-25 Thread Dominik Luecke
Hello, it looks quite similar, but it is not completely what I need, I rather need something like inParallel = parMap rwhnf outList = inParallel (map f) listOfLists If I use your construction on the first 2 elements of my list, I see several threads working, but not in the other case.

[Haskell-cafe] Re: Haskell Paralellism

2007-10-25 Thread Simon Marlow
Dominik Luecke wrote: I am trying to use the code rels list = let o1 = (map makeCompEntry) $ head $ splitList list o2 = (map makeCompEntry) $ head $ tail $ splitList list o3 = (map makeCompEntry) $ head $ tail $ tail $ splitList list in case (head $

Re: [Haskell-cafe] Binary constants in Haskell

2007-10-25 Thread Josef Svenningsson
On 10/24/07, Neil Mitchell [EMAIL PROTECTED] wrote: Hi Are there binary constants in Haskell, as we have, for instance, 0o232 for octal and 0xD29A for hexadecimal? No, though it is an interesting idea. You can get pretty close with existing Haskell though: (bin 100010011)

Re: [Haskell-cafe] freebsd-7.0BETA1 and ghc

2007-10-25 Thread Maxime Henrion
brad clawsie wrote: On Wed, Oct 24, 2007 at 06:14:49PM -0400, Xiao-Yong Jin wrote: Is there any hope for it to be fixed before the freeze of ports tree? i believe that is the purpose of the extended beta/rc period, to allow ports maintainers a chance to get things fixed before the main

Re: [Haskell-cafe] Binary constants in Haskell

2007-10-25 Thread Dusan Kolar
Hello all, // PLS, no flame I think the question was not whether there's a way, how to handle the problem of encryption of a binary number to anything suitable and, more or less, readable by a human and transforming it to a binary form, but whether there's such a literal or not and whether

Re: [Haskell-cafe] Binary constants in Haskell

2007-10-25 Thread Ketil Malde
Dusan Kolar [EMAIL PROTECTED] writes: // PLS, no flame I apologize if my post came across as such, that was certainly not the intent. I think the question was [..] whether there's such a literal or not and whether it is bad idea to have something like 0b10111011. I agree. From my point

Re: [Haskell-cafe] Binary constants in Haskell

2007-10-25 Thread Iavor Diatchki
Hi, We have no binary literals in Haskell and there are situations when it would have been useful to have this feature (e.g., if the spec of something that you are working with is already provided using this notation). While it may be useful to have overloaded binary literals in the usual

[Haskell-cafe] lazily traversing a foreign data structure

2007-10-25 Thread Graham Fawcett
Hi folks, I'm writing a Gnu DBM module as an exercise for learning Haskell and its FFI. I'm wondering how I might write a function that returns the database keys as a lazy list. I've wrapped the two relevant foreign functions: firstKey :: Ptr Db - IO (Maybe String) nextKey :: Ptr Db -

Re: [Haskell-cafe] Existential types (Was: Type vs TypeClass duality)

2007-10-25 Thread apfelmus
Ryan Ingram wrote: On 10/24/07, apfelmus [EMAIL PROTECTED] wrote: So, instead of storing a list [∃a. Show a = a], you may as well store a list of strings [String]. I've seen this before, and to some extent I agree with it, but it breaks down for bigger examples due to sharing. In most

Re: [Haskell-cafe] Binary constants in Haskell

2007-10-25 Thread Stefan O'Rear
On Thu, Oct 25, 2007 at 02:40:36PM +0200, Josef Svenningsson wrote: On 10/24/07, Neil Mitchell [EMAIL PROTECTED] wrote: Hi Are there binary constants in Haskell, as we have, for instance, 0o232 for octal and 0xD29A for hexadecimal? No, though it is an interesting idea.

Re: [Haskell-cafe] Binary constants in Haskell

2007-10-25 Thread Claus Reinke
From my point of view, the difference between 0b10111011 and (bin[1,0,1,1,1,0,1,1]) is 22-10 that is 12 characters. how about using ghc's new overloaded strings for this? 10111011::Binary there used to be a way to link to ghc head's docs, but i can't find it right now. the test is

Re: [Haskell-cafe] Binary constants in Haskell

2007-10-25 Thread Don Stewart
claus.reinke: From my point of view, the difference between 0b10111011 and (bin[1,0,1,1,1,0,1,1]) is 22-10 that is 12 characters. how about using ghc's new overloaded strings for this? 10111011::Binary there used to be a way to link to ghc head's docs, but i can't find it right

Re: [Haskell-cafe] Binary constants in Haskell

2007-10-25 Thread Don Stewart
dons: claus.reinke: From my point of view, the difference between 0b10111011 and (bin[1,0,1,1,1,0,1,1]) is 22-10 that is 12 characters. how about using ghc's new overloaded strings for this? 10111011::Binary there used to be a way to link to ghc head's docs, but i

Re: [Haskell-cafe] lazily traversing a foreign data structure

2007-10-25 Thread Derek Elkins
On Thu, 2007-10-25 at 11:30 -0400, Graham Fawcett wrote: Hi folks, I'm writing a Gnu DBM module as an exercise for learning Haskell and its FFI. I'm wondering how I might write a function that returns the database keys as a lazy list. I've wrapped the two relevant foreign functions:

Re: [Haskell-cafe] lazily traversing a foreign data structure

2007-10-25 Thread Graham Fawcett
On 10/25/07, Derek Elkins [EMAIL PROTECTED] wrote: On Thu, 2007-10-25 at 11:30 -0400, Graham Fawcett wrote: I'm writing a Gnu DBM module as an exercise for learning Haskell and its FFI. I'm wondering how I might write a function that returns the database keys as a lazy list. I've wrapped

Re: [Haskell-cafe] ANN: Math.OEIS 0.1

2007-10-25 Thread Carl Witty
On Mon, 2007-10-22 at 10:54 -0400, Brent Yorgey wrote: The Online Encyclopedia of Integer Sequences should really contain more Haskell code for describing the sequences. Agreed! I propose an OEIS party where we all sit around one day and submit Haskell

Re: [Haskell-cafe] lazily traversing a foreign data structure

2007-10-25 Thread Brandon S. Allbery KF8NH
On Oct 25, 2007, at 13:04 , Derek Elkins wrote: Just use unsafeInterleaveIO in the obvious definition to read all the keys. That said, it's not called unsafeInterleaveIO for no reason. I think it might actually be safe in this case: if the file changes out from under your lazy I/O, far

Re: [Haskell-cafe] lazily traversing a foreign data structure

2007-10-25 Thread Ryan Ingram
On 10/25/07, Brandon S. Allbery KF8NH [EMAIL PROTECTED] wrote: I think it might actually be safe in this case: if the file changes out from under your lazy I/O, far worse things happen in the gdbm library layer than in the unsafe-IO Haskell layer. Right, but if you do something like do

Re: [Haskell-cafe] lazily traversing a foreign data structure

2007-10-25 Thread Brandon S. Allbery KF8NH
On Oct 25, 2007, at 14:21 , Ryan Ingram wrote: On 10/25/07, Brandon S. Allbery KF8NH [EMAIL PROTECTED] wrote: I think it might actually be safe in this case: if the file changes out from under your lazy I/O, far worse things happen in the gdbm library layer than in the unsafe-IO Haskell

Re: [Haskell-cafe] Existential types (Was: Type vs TypeClass duality)

2007-10-25 Thread Wouter Swierstra
In a sense, that's also the reason why stream fusion à la Duncan + Roman + Don uses an existential type data Stream a where Stream :: ∀s. s - (s - Step a s) - Stream a data Step a s = Done | Yield a s | Skip s I thought there was a deeper reason for

Re: [Haskell-cafe] Binary constants in Haskell

2007-10-25 Thread Henning Thielemann
On Thu, 25 Oct 2007, Don Stewart wrote: claus.reinke: how about using ghc's new overloaded strings for this? 10111011::Binary there used to be a way to link to ghc head's docs, but i can't find it right now. the test is

Re: [Haskell-cafe] lazily traversing a foreign data structure

2007-10-25 Thread Graham Fawcett
On 10/25/07, Brandon S. Allbery KF8NH [EMAIL PROTECTED] wrote: On Oct 25, 2007, at 14:21 , Ryan Ingram wrote: Right, but if you do something like do keys - getKeysLazy db [.. some computation A here that may or may not evaluate all the keys ..] addRow db newRow [.. some

Re: [Haskell-cafe] Binary constants in Haskell

2007-10-25 Thread Henning Thielemann
On Thu, 25 Oct 2007, Stefan O'Rear wrote: On Thu, Oct 25, 2007 at 02:40:36PM +0200, Josef Svenningsson wrote: On 10/24/07, Neil Mitchell [EMAIL PROTECTED] wrote: You can get pretty close with existing Haskell though: (bin 100010011) where bin :: Integer - Integer, and is

Re: [Haskell-cafe] Binary constants in Haskell

2007-10-25 Thread Stefan O'Rear
On Thu, Oct 25, 2007 at 09:41:27PM +0200, Henning Thielemann wrote: Total functions, full laziness, and compile time evaluation of finite non-bottom CAFs... If I write a program that approximates a big but fixed number of digits of Pi - how can we prevent the compiler from computing Pi,

Re: [Haskell-cafe] Binary constants in Haskell

2007-10-25 Thread Henning Thielemann
On Thu, 25 Oct 2007, Stefan O'Rear wrote: On Thu, Oct 25, 2007 at 09:41:27PM +0200, Henning Thielemann wrote: Total functions, full laziness, and compile time evaluation of finite non-bottom CAFs... If I write a program that approximates a big but fixed number of digits of Pi - how

Re: [Haskell-cafe] ANN: Math.OEIS 0.1

2007-10-25 Thread Jacques Carette
Carl Witty wrote: On Mon, 2007-10-22 at 10:54 -0400, Brent Yorgey wrote: The Online Encyclopedia of Integer Sequences should really contain more Haskell code for describing the sequences. Agreed! I propose an OEIS party where we all sit around one day and

Re: [Haskell-cafe] lazily traversing a foreign data structure

2007-10-25 Thread Ryan Ingram
On 10/25/07, Brandon S. Allbery KF8NH [EMAIL PROTECTED] wrote: My point is that there's no promise for that one *even in C*. (The equivalent construct being adding the new row before nextKey has failed.) Sure, but in C, it's highly likely that the full evaluation of the key list happens in

[Haskell-cafe] List comprehension order of evaluation

2007-10-25 Thread Maurí­cio
Hi, Today, if I write: [a:[b] | a-ab , b-12] I get: [a1,a2,b1,b2] Are there any guarantees that I'll never get [a1,b1,a2,b2] instead, i.e., that the first list will always be the last one to be fully transversed? Even if I use a different compiler or a future version of Haskell? Reading how

Re: [Haskell-cafe] List comprehension order of evaluation

2007-10-25 Thread Jonathan Cast
On Thu, 2007-10-25 at 19:59 -0200, Maurí­cio wrote: Hi, Today, if I write: [a:[b] | a-ab , b-12] I get: [a1,a2,b1,b2] Are there any guarantees that I'll never get [a1,b1,a2,b2] instead, i.e., that the first list will always be the last one to be fully transversed? Even if I

Re: [Haskell-cafe] List comprehension order of evaluation

2007-10-25 Thread Thomas Hartman
If I understand list comprehensions correctly, what you wrote is the same as do a - ab; b - 12; [a:[b]] which is the same as ab == \a - do b - 12; [a:[b]] which is the same as ab = \a - 12 = \b - [a:[b]] which is the same as concat $ map ( \a - 12 = \b - [a:[b]] ) ab

Re: [Haskell-cafe] Binary constants in Haskell

2007-10-25 Thread John Meacham
On Thu, Oct 25, 2007 at 04:06:56PM +0200, Dusan Kolar wrote: Hello all, // PLS, no flame I think the question was not whether there's a way, how to handle the problem of encryption of a binary number to anything suitable and, more or less, readable by a human and transforming it to a

Re: [Haskell-cafe] Binary constants in Haskell

2007-10-25 Thread John Meacham
On Thu, Oct 25, 2007 at 09:52:27AM -0700, Don Stewart wrote: dons: claus.reinke: From my point of view, the difference between 0b10111011 and (bin[1,0,1,1,1,0,1,1]) is 22-10 that is 12 characters. how about using ghc's new overloaded strings for this? 10111011::Binary

[Haskell-cafe] Unfoldr love

2007-10-25 Thread Justin Bailey
In my best Homer Simposon voice - unfoldr - is there anything it can't do? I have strange unfoldr love right now. I'm probably too impressed by this function, but it takes a string and splits it into a list of words, while keeping quoted phrases together: import Data.List

[Haskell-cafe] Haskell Weekly News: October 25, 2007

2007-10-25 Thread Don Stewart
--- Haskell Weekly News http://sequence.complete.org/hwn/20071025 Issue 66 - October 25, 2007 --- Welcome to issue 66 of HWN, a newsletter covering

Re: [Haskell-cafe] Re: Hiding side effects in a data structure

2007-10-25 Thread John Meacham
On Tue, Oct 23, 2007 at 10:01:37AM +0100, Jon Fairbairn wrote: That sort of misses my point. Given the length of time I've been involved with it, I hardly need encouragement to use Haskell, but if even I find getting to the documentation off-putting, having to know a trick to do it isn't