Re: [Haskell-cafe] Obscure weirdness

2009-06-21 Thread Raynor Vliegendhart
On 6/20/09, Andrew Coppin andrewcop...@btinternet.com wrote: Is this a known bug in GHC 6.10.1? Will upgrading fix it? (Obviously, it's quite a lot of work to change GHC.) Suffice it to say that my program is quite big and complicated; it worked fine when it was still small and simple. ;-)

[Haskell-cafe] Edinburgh Haskell users meeting this afternoon

2009-06-21 Thread Dougal Stanton
Hello Haskell users If you're in the Edinburgh (Scotland!) area and interested in Haskell we may have just the thing for you. I will be meeting one other Haskell Cafe list member at Doctor's pub at 4pm this afternoon (Sunday 21 June). This could be the start of something bigger, so if you're

Re: [Haskell-cafe] Obscure weirdness

2009-06-21 Thread Andrew Coppin
Raynor Vliegendhart wrote: There is a bug in ghci 6.10.1 that seems to be fixed in 6.10.3 (not sure whether it's fixed in 6.10.3). Certain non-terminating expressions causes ghci to crash immediately and go back to the prompt: C:\ghci GHCi, version

Re: [Haskell-cafe] Obscure weirdness

2009-06-21 Thread Andrew Coppin
Andrew Coppin wrote: Anyway, I shall try 6.10.3 and see what happens. Recompiled my program. It now throws a loop exception (which the exception handler catches) instead of just dying. (Curiosly, the exception handler itself then throws an exception saying stdin: hGetLine: illegal

[Haskell-cafe] Nested tests [Code walking off the right edge of the screen]

2009-06-21 Thread Andrew Coppin
Deniz Dogan wrote: I (too) often find myself writing code such as this: if something then putStrLn howdy there! else if somethingElse then putStrLn howdy ho! else ... I recall reading some tutorial about how you can use the Maybe monad if your code starts looking like

Re: [Haskell-cafe] Nested tests [Code walking off the right edge of the screen]

2009-06-21 Thread Bulat Ziganshin
Hello Andrew, Sunday, June 21, 2009, 1:52:22 PM, you wrote: d1x - doesDirectoryExist d1 if d1x then do f1x - doesFileExist (d1 / f1) if f1x then do d2x - doesDirectoryExist d2 if d2x then do f2x - doesFileExist

Re: [Haskell-cafe] Code walking off the right edge of the screen

2009-06-21 Thread Claus Reinke
I (too) often find myself writing code such as this: if something then putStrLn howdy there! else if somethingElse then putStrLn howdy ho! else ... 1. recognize something odd. done. 2. look for improvements. good. 3. define suitable abstractions for your special case 4.

Re: [Haskell-cafe] Nested tests [Code walking off the right edge of the screen]

2009-06-21 Thread Sebastian Fischer
On Jun 21, 2009, at 11:52 AM, Andrew Coppin wrote: In a similar vein: d1x - doesDirectoryExist d1 if d1x then do f1x - doesFileExist (d1 / f1) if f1x then do d2x - doesDirectoryExist d2 if d2x then do f2x - doesFileExist (d2 / f2) if

Re: [Haskell-cafe] Nested tests [Code walking off the right edge of the screen]

2009-06-21 Thread Andrew Coppin
Sebastian Fischer wrote: using Control.Monad.Error: either (hPutStrLn stderr) return = runErrorT $ do d1x - lift $ doesDirectoryExist d1 unless d1x $ fail Directory ++ d1 ++ not found. f1x - lift $ doesFileExist (d1 / f1) unless f1x $ fail File ++ f1 ++ not found. d2x

Re: [Haskell-cafe] Nested tests [Code walking off the right edge of the screen]

2009-06-21 Thread Sebastiaan Visser
On Jun 21, 2009, at 2:36 PM, Sebastian Fischer wrote: On Jun 21, 2009, at 11:52 AM, Andrew Coppin wrote: ... When using failUnless boolAction message = lift boolAction = (`unless`fail message) the code becomes either (hPutStrLn stderr) return = runErrorT $ do failUnless

[Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Andrew Coppin
OK, so I'm guessing there might be one or two (!) people around here who know something about the Lambda calculus. I've written a simple interpretter that takes any valid Lambda expression and performs as many beta reductions as possible. When the input is first received, all the variables

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Keith Sheppard
forgot to cc the cafe :-) On Sun, Jun 21, 2009 at 1:08 PM, Keith Sheppardkeiths...@gmail.com wrote: hmm, it's been a while but... i think this infinite loop with a free variable would cause collision (\a . a a) (\b . b b d) On Sun, Jun 21, 2009 at 12:53 PM, Andrew

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Miguel Mitrofanov
An answer would probably depend on the reductions order you've chosen. Would that do? (\e - e (\u - e (\v - u))) (\f - \x - f x) -- all variables have different names, see? = (\f - \x - f x) (\u - (\f - \x - f x) (\v - u)) = \x - (\u - (\f - \x - f x) (\v - u)) x = \x - (\f - \x - f x)

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Victor Nazarov
On Sun, Jun 21, 2009 at 8:53 PM, Andrew Coppinandrewcop...@btinternet.com wrote: OK, so I'm guessing there might be one or two (!) people around here who know something about the Lambda calculus. I've written a simple interpretter that takes any valid Lambda expression and performs as many

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Deniz Dogan
2009/6/21 Andrew Coppin andrewcop...@btinternet.com: OK, so I'm guessing there might be one or two (!) people around here who know something about the Lambda calculus. I've written a simple interpretter that takes any valid Lambda expression and performs as many beta reductions as possible.

Re: [Haskell-cafe] packages on Hackage?

2009-06-21 Thread Duncan Coutts
On Thu, 2009-06-18 at 23:26 -0500, Vasili I. Galchin wrote: Hello, Haskell packages on Hackage can be hosted anywhere, yes? Yes. If a Haskell package is hosted on Hackage, how often is it backed up? It's not especially wise to rely on Hackage for your backup needs since it

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Miguel Mitrofanov
Correction: I think that one can find an expression that causes name clashes anyway, I'm just not certain that there is one that would clash independent of whichever order you choose. On 21 Jun 2009, at 21:12, Miguel Mitrofanov wrote: An answer would probably depend on the reductions order

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Keith Sheppard
scratch that... it's completely wrong On Sun, Jun 21, 2009 at 1:09 PM, Keith Sheppardkeiths...@gmail.com wrote: forgot to cc the cafe :-) On Sun, Jun 21, 2009 at 1:08 PM, Keith Sheppardkeiths...@gmail.com wrote: hmm, it's been a while but... i think this infinite loop with a free variable

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Lauri Alanko
On Sun, Jun 21, 2009 at 05:53:04PM +0100, Andrew Coppin wrote: I've written a simple interpretter that takes any valid Lambda expression and performs as many beta reductions as possible. When the input is first received, all the variables are renamed to be unique. Question: Does this

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Brent Yorgey
On Sun, Jun 21, 2009 at 05:53:04PM +0100, Andrew Coppin wrote: OK, so I'm guessing there might be one or two (!) people around here who know something about the Lambda calculus. I've written a simple interpretter that takes any valid Lambda expression and performs as many beta reductions as

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Bertram Felgenhauer
Miguel Mitrofanov wrote: Correction: I think that one can find an expression that causes name clashes anyway, I'm just not certain that there is one that would clash independent of whichever order you choose. Yes there is. Consider (\f g - f (f (f (f (f (f g)) (\l a b - l (b a)) (\x -

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Andrew Coppin
Lauri Alanko wrote: With name collisions I'm assuming you mean inadvertent variable capture. The answer depends on your evaluation strategy. If you never reduce inside a lambda (e.g. call-by-name or call-by-value), then you will always be substituting a closed term in place of a variable, and

[Haskell-cafe] secure store for passwords on CLIENT side

2009-06-21 Thread Iliya Kuznetsov
Hello, haskellers, I've faced with some issue: how to store passwords securely on client's side? Of course there are many technics how to hash them on server side but sure all of them can't be used in my case (because of nature of hash). There is some platform-independent application written on

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Miguel Mitrofanov
Wow. Now you've showed it to me, it seems pretty obvious. That's what I like about math. On 21 Jun 2009, at 21:56, Bertram Felgenhauer wrote: Miguel Mitrofanov wrote: Correction: I think that one can find an expression that causes name clashes anyway, I'm just not certain that there is one

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Miguel Mitrofanov
Probably the easiest way to fix this was already proposed by Deniz Dogan: de Bruijn indices. On 21 Jun 2009, at 21:57, Andrew Coppin wrote: Lauri Alanko wrote: With name collisions I'm assuming you mean inadvertent variable capture. The answer depends on your evaluation strategy. If you

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Andrew Coppin
Andrew Coppin wrote: Ladies and gentlemen, we have a counter-example! (\x1 - x1 x1) (\y2 - \z3 - y2 z3) (\y2 - \z3 - y2 z3) (\y2 - \z3 - y2 z3) \z3 - (\y2 - \z3 - y2 z3) z3 \z3 - \z3 - z3 z3 Now the operative question becomes... how in the name of God to I fix this? (The obvious

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Andrew Coppin
Andrew Coppin wrote: Well anyway, the obvious thing to do is after each reduction, strip off all the variable indicies and rerun the labeller to assign new indicies. But does this solution work properly in general? No. Supposing some Lambda expression eventually reduces to, say, \x1 - \x2

[Haskell-cafe] Type system trickery

2009-06-21 Thread Andrew Coppin
I have a datatype with about a dozen constructors. I'd like to find a way to use the type system to prevent one of the constructors from being used in certain places. But I can't think of a way to do that. data Foobar = Foo Foobar | Bar Foobar | Zoo Foobar I want the type system to

Re: [Haskell-cafe] Type system trickery

2009-06-21 Thread Daniel Fischer
Am Sonntag 21 Juni 2009 21:24:24 schrieb Andrew Coppin: I have a datatype with about a dozen constructors. I'd like to find a way to use the type system to prevent one of the constructors from being used in certain places. But I can't think of a way to do that. data Foobar = Foo Foobar

Re: [Haskell-cafe] Type system trickery

2009-06-21 Thread Andrew Coppin
Niklas Broberg wrote: On Sun, Jun 21, 2009 at 9:24 PM, Andrew Coppinandrewcop...@btinternet.com wrote: data Foobar = Foo Foobar | Bar Foobar | Zoo Foobar I want the type system to track whether or not Zoo has been used in a specific value. Sure, you can check for it at runtime, but

[Haskell-cafe] Optimizing spelling correction program

2009-06-21 Thread Kamil Dworakowski
Hi all, I want to learn how to optimize Haskell code on the Norvig's spelling correction program [1]. Peter Norvig has written the program in Python, quite a literate translation to Haskell (thanks to Grzegorz Chrupala) [2] was also available. Both versions are about 23 LOCs, and Haskell version

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Jeremy Shaw
Hello, Have you read the lambda calculus chapter in: The Implementation of Functional Programming Languages by Simon Peyton Jones, published by Prentice Hall, 1987: http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/ - jeremy

Re: [Haskell-cafe] Type system trickery

2009-06-21 Thread Niklas Broberg
On Sun, Jun 21, 2009 at 9:24 PM, Andrew Coppinandrewcop...@btinternet.com wrote: I have a datatype with about a dozen constructors. I'd like to find a way to use the type system to prevent one of the constructors from being used in certain places. But I can't think of a way to do that.  data

Re: [Haskell-cafe] Type system trickery

2009-06-21 Thread Andrew Coppin
Niklas Broberg wrote: That's what GADTs are for: data Flag = HasZoo | NoZoo data Foobar a where Foo :: Foobar a - Foobar a Bar :: Foobar a - Foobar a Zoo :: Foobar a - Foobar HasZoo Ouch #1: This appears to instantly disable deriving the Eq, Ord and Show instances I want. :-/

Re: [Haskell-cafe] Type system trickery

2009-06-21 Thread Niklas Broberg
That's what GADTs are for: data Flag = HasZoo | NoZoo Eh, I wrote this a bit fast obviously (no dependent types here). Like Daniel Fischer wrote, these should rather be separate data types, i.e. data HasZoo data NoZoo The rest is still correct though. data Foobar a where  Foo :: Foobar a

Re: [Haskell-cafe] Optimizing spelling correction program

2009-06-21 Thread Don Stewart
kamil: Hi all, I want to learn how to optimize Haskell code on the Norvig's spelling correction program [1]. Peter Norvig has written the program in Python, quite a literate translation to Haskell (thanks to Grzegorz Chrupala) [2] was also available. Both versions are about 23 LOCs, and

Re: [Haskell-cafe] Type system trickery

2009-06-21 Thread David Menendez
On Sun, Jun 21, 2009 at 4:00 PM, Andrew Coppinandrewcop...@btinternet.com wrote: Niklas Broberg wrote: On Sun, Jun 21, 2009 at 9:24 PM, Andrew Coppinandrewcop...@btinternet.com wrote: I want the type system to track whether or not Zoo has been used in a specific value. Sure, you can check

Re: [Haskell-cafe] Type system trickery

2009-06-21 Thread Andrew Coppin
David Menendez wrote: If you don't need code that's polymorphic between Foobar HasZoo and Foobar NoZoo, you could just newtype Foobar and only export smart constructors. Unfortunately I want to be able to print both of them out. (After all, the printing algorithm is identical whether Zoo

Re: [Haskell-cafe] secure store for passwords on CLIENT side

2009-06-21 Thread Magnus Therning
Iliya Kuznetsov wrote: Hello, haskellers, I've faced with some issue: how to store passwords securely on client's side? Of course there are many technics how to hash them on server side but sure all of them can't be used in my case (because of nature of hash). There is some

[Haskell-cafe] Re: Optimizing spelling correction program

2009-06-21 Thread Kamil Dworakowski
What are the keys in your Map? Strict ByteStrings? And you're using ghc 6.10.x? For the record, I use 6.10.1 and strict ByteString everywhere now. I used to have some lazy IO with vanilla strings, but switching to Data.ByteString.Char8.readFile didn't change the time at all. The big.txt is

[Haskell-cafe] Suggestion for Network.Socket in regards to PortNumber

2009-06-21 Thread John Van Enk
Hello List, Is there any one else in favor of hiding the PortNum constructor in Network.Socket in the next release? Here's why: Prelude :m + Network.Socket Data.Word Prelude Network.Socket Data.Word let p = 5000 :: Word16 Prelude Network.Socket Data.Word let p' = PortNum p Prelude Network.Socket

Re: [Haskell-cafe] Suggestion for Network.Socket in regards to PortNumber

2009-06-21 Thread Donn Cave
Quoth John Van Enk vane...@gmail.com, [... example showing that PortNum is stored in network byte order ] Notice that using the PortNum constructor does not at all do what the user expects. This really should be a hidden constructor. Could you elaborate, what does the user expect?

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Lennart Augustsson
As others have pointed out, it is not enough to rename before reduction. It should be pretty obvious since when you do substitution and copy a lambda expression into more than once place you will introduce variables with the same name. You can keep unique variables by cloning during substitution,

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Lennart Augustsson
Actually, keeping all names distinct is not de Bruijn numbering, it's called the Barendregt convention. On Sun, Jun 21, 2009 at 7:05 PM, Deniz Dogandeniz.a.m.do...@gmail.com wrote: 2009/6/21 Andrew Coppin andrewcop...@btinternet.com: OK, so I'm guessing there might be one or two (!) people

Re: [Haskell-cafe] Suggestion for Network.Socket in regards to PortNumber

2009-06-21 Thread John Van Enk
On Sun, Jun 21, 2009 at 6:02 PM, Donn Caved...@avvanta.com wrote: Could you elaborate, what does the user expect? Users will probably expect (PortNum 0x2000) to represent a port number of 0x2000 (8192), not 0x0020 (32). /jve ___ Haskell-Cafe mailing

Re: [Haskell-cafe] Suggestion for Network.Socket in regards to PortNumber

2009-06-21 Thread Thomas DuBuisson
I'm in favor of the entire Network library being reworked with an improved API that is higher level and type-safe instead of a direct translation/FFI of Berkeley sockets. I also would like the Network package to export Data instances for headers while taking advantage of pretty, prettyclass, and

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Brent Yorgey
On Sun, Jun 21, 2009 at 07:48:30PM +0100, Andrew Coppin wrote: Andrew Coppin wrote: Well anyway, the obvious thing to do is after each reduction, strip off all the variable indicies and rerun the labeller to assign new indicies. But does this solution work properly in general? No.

[Haskell-cafe] Re: ANN: haskell-src-exts 1.0.0 rc1 (aka 0.5.2)

2009-06-21 Thread Niklas Broberg
Dear all, I'm pleased to announce to you haskell-src-exts-0.5.7, which is truly the first *real* release candidate for 1.0.0. By real, I mean that I could consider releasing it in this state. It is feature complete, fully documented, and has no remaining known bugs. But before I do, I'd like to

Re: [Haskell-cafe] Slightly off-topic: Lambda calculus

2009-06-21 Thread Thomas DuBuisson
All, Just as ancillary information: ∃ a calculator on Hackage called LambdaCalculator. Its rather short (loc wise) and fun to play with. Thomas On Sun, Jun 21, 2009 at 10:57 AM, Andrew Coppinandrewcop...@btinternet.com wrote: Lauri Alanko wrote: With name collisions I'm assuming you mean

[Haskell-cafe] Cross platform getProcessID

2009-06-21 Thread John Van Enk
In the unix package, we have getProcessID. Is there a corresponding method for finding the process ID in Windows? /jve ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] packages on Hackage?

2009-06-21 Thread Vasili I. Galchin
ok ... thx On Sun, Jun 21, 2009 at 12:14 PM, Duncan Coutts duncan.cou...@worc.ox.ac.uk wrote: On Thu, 2009-06-18 at 23:26 -0500, Vasili I. Galchin wrote: Hello, Haskell packages on Hackage can be hosted anywhere, yes? Yes. If a Haskell package is hosted on Hackage, how

[Haskell-cafe] coding standard question

2009-06-21 Thread Vasili I. Galchin
Hello, I am working with some existing code. where/let functions use the same name for function parameters as the outer function and hence there is a shadow warning from the compiler. To me it doesn't see totally unreasonable to code like this the downside is the nasty ghc warnings. Is

Re: [Haskell-cafe] coding standard question

2009-06-21 Thread Erik de Castro Lopo
Vasili I. Galchin wrote: I am working with some existing code. where/let functions use the same name for function parameters as the outer function and hence there is a shadow warning from the compiler. To me it doesn't see totally unreasonable to code like this the downside is the

[Haskell-cafe] haskelldb + sqlite problem.

2009-06-21 Thread Magicloud Magiclouds
Hi, I am using haskelldb and haskelldb-hdbc-sqlite3. Well, I finally got the source compiled and ran, I got this error: App: user error (SQL error: SqlError {seState = , seNativeError = 21, seErrorMsg = prepare 74: SELECT subject,\n timestamp\nFROM notes as T1\nORDER BY timestamp DESC:

Re: [Haskell-cafe] coding standard question

2009-06-21 Thread Deniz Dogan
2009/6/22 Vasili I. Galchin vigalc...@gmail.com: Hello, I am working with some existing code. where/let functions use the same name for function parameters as the outer function and hence there is a shadow warning from the compiler. To me it doesn't see totally unreasonable to code like

Re: [Haskell-cafe] coding standard question

2009-06-21 Thread Magnus Therning
Erik de Castro Lopo wrote: Vasili I. Galchin wrote: I am working with some existing code. where/let functions use the same name for function parameters as the outer function and hence there is a shadow warning from the compiler. To me it doesn't see totally unreasonable to code like this

Re: [Haskell-cafe] Optimizing spelling correction program

2009-06-21 Thread Bulat Ziganshin
Hello Kamil, Monday, June 22, 2009, 12:01:40 AM, you wrote: Right... Python uses hashtables while here I have a tree with log n you can try this pure hashtable approach: import Prelude hiding (lookup) import qualified Data.HashTable import Data.Array import qualified Data.List as List data