Re: [Haskell-cafe] Re: HDBC, character encoding

2008-04-03 Thread Peter Gammie
On 03/04/2008, at 9:10 PM, John Goerzen wrote: On 2008-04-01, Peter Gammie <[EMAIL PROTECTED]> wrote: I added some stuff to HSQL (not HDBC) and HaskellDB so that UTF8 can be used to talk to the database. It's not very pretty though, so I haven't tried to get it merged. Do you have a diff some

Re: [Haskell-cafe] Re: Doing without IORef

2008-04-03 Thread ajb
G'day all. Quoting Jinwoo Lee <[EMAIL PROTECTED]>: Thanks everyone! Now I think using IORef is the most practical way to do this. Just a suggestion: Store it in a ReaderT instead of a StateT. Cheers, Andrew Bromage ___ Haskell-Cafe mailing list Has

Re: [Haskell-cafe] Doing without IORef

2008-04-03 Thread Jinwoo Lee
OK. I understand it now. I think the article Claude suggested is worth a read because it shows how to hide using IORef in simple APIs. Thanks, jinwoo On Fri, Apr 4, 2008 at 10:17 AM, Brandon S. Allbery KF8NH < [EMAIL PROTECTED]> wrote: > > On Apr 3, 2008, at 21:07 , Jinwoo Lee wrote: > > > But

Re: [Haskell-cafe] Doing without IORef

2008-04-03 Thread Brandon S. Allbery KF8NH
On Apr 3, 2008, at 21:07 , Jinwoo Lee wrote: But I still have to use IORef this way. You can't escape the IORef unless you can convince the library to thread your state everywhere that it needs to be modified *and* where it needs to be read, without copying it. -- brandon s. allbery [sol

Re: [Haskell-cafe] Re: Doing without IORef

2008-04-03 Thread Jinwoo Lee
Thanks everyone! Now I think using IORef is the most practical way to do this. And Claude, I will look into the article that you mentioned. jinwoo On Fri, Apr 4, 2008 at 3:08 AM, Peter Hercek <[EMAIL PROTECTED]> wrote: > Jinwoo Lee wrote: > > > Is there any way in which I can do without IORef i

Re: [Haskell-cafe] Doing without IORef

2008-04-03 Thread Jinwoo Lee
But I still have to use IORef this way. On Thu, Apr 3, 2008 at 7:08 PM, Alfonso Acosta <[EMAIL PROTECTED]> wrote: > > type MyState a = StateT FilePath IO a > > > > > Is there any way in which I can do without IORef in tabHandler and > > commandLoop (written in red and bold, if you can see)? > >

Re: [Haskell-cafe] [GSoC] Porting HaRe to use the GHC API

2008-04-03 Thread Claus Reinke
|Another notion I was interested in was to be able to reproduce a |sequence of multi-module refactorings even in the absence of the |initial module. It would allow to present a kind of "interface diff" |for a distribution which would allow the developer of a module which |depends on the distributi

Re: [Haskell-cafe] Shouldn't this loop indefinitely => take (last [0..]) [0..]

2008-04-03 Thread Jeremy Shaw
Hello, Sadly, as others have pointed out, [0..] is not an infinite list in that context, so nothing too exciting is happening. You can making something almost exciting happen if you define some Peano numbers: > data P = Z | S P > inf = S Z [bunch of class instances skipped] > main = print $ ge

Re: [Haskell-cafe] compile-time question

2008-04-03 Thread Bulat Ziganshin
Hello Galchin, Friday, April 4, 2008, 2:50:42 AM, you wrote: > 3) runhaskell Setup.hs install  >   > I write a small test case that references one of the new > functions; however, when I build the test case, I get an "Out of > scope" message indicated that at ghc(i) compile time the new functi

[Haskell-cafe] compile-time question

2008-04-03 Thread Galchin Vasili
hello, I have added new function definitions to the namespace of an existing module. I did 1: runhaskell Setup.hs configure 2. runhaskell Setup.hs build 3) runhaskell Setup.hs install successfully so that a Linux .a(rchive) is installed. I write a small test case that references one of th

Re: [Haskell-cafe] Re: Shouldn't this loop indefinitely => take (last [0..]) [0..]

2008-04-03 Thread Olivier Boudry
On Thu, Apr 3, 2008 at 11:13 PM, Don Stewart <[EMAIL PROTECTED]> wrote: > length, take, drop and index working on machine-sized Ints by default > are really a bit of a wart, aren't they? > > -- Don Agreed, Olivier. ___ Haskell-Cafe mailing list Haskel

Re: [Haskell-cafe] Re: Shouldn't this loop indefinitely => take (last [0..]) [0..]

2008-04-03 Thread Bryan O'Sullivan
Don Stewart wrote: >> Which, incidentally, also explains why Don couldn't reproduce it on a 64- >> bit system. There, instead of hanging for about a minute before printing >> out the list, it would hang for about 4 billion minutes. A billion minutes here, a billion minutes there, and pretty soo

Re: [Haskell-cafe] Re: Shouldn't this loop indefinitely => take (last [0..]) [0..]

2008-04-03 Thread Don Stewart
cdsmith: > Bryan O'Sullivan wrote: > > It's not an infinite list. It's a list of length maxBound::Int, as > > required by the fact that take's first argument is an Int. The second > > argument is probably defaulting to Integer. > > Which, incidentally, also explains why Don couldn't reproduce it

[Haskell-cafe] Re: Shouldn't this loop indefinitely => take (last [0..]) [0..]

2008-04-03 Thread Chris Smith
Bryan O'Sullivan wrote: > It's not an infinite list. It's a list of length maxBound::Int, as > required by the fact that take's first argument is an Int. The second > argument is probably defaulting to Integer. Which, incidentally, also explains why Don couldn't reproduce it on a 64- bit system.

Re: [Haskell-cafe] Shouldn't this loop indefinitely => take (last [0..]) [0..]

2008-04-03 Thread Olivier Boudry
On Thu, Apr 3, 2008 at 10:35 PM, Bryan O'Sullivan <[EMAIL PROTECTED]> wrote: > > It's not an infinite list. It's a list of length maxBound::Int, as > required by the fact that take's first argument is an Int. The second > argument is probably defaulting to Integer. > > Right! The first arg of "t

[Haskell-cafe] Re: Precedence (Part 2)

2008-04-03 Thread Chris Smith
PR Stanley wrote: Just a meta-point. The dash-dash-space sequence introduces a signature. If you write your reply after the dash-dash-space, as you did here, a lot of us won't see your reply because we have our mail/news clients set up to ignore signatures. I had to view the original message

Re: [Haskell-cafe] Shouldn't this loop indefinitely => take (last [0..]) [0..]

2008-04-03 Thread Bryan O'Sullivan
Olivier Boudry wrote: > main = do > putStrLn $ show $ take (last [0..]) [0..] > > or simply run: > > take (last [0..]) [0..] > > in ghci, it first hang for about one minute and then starts to generate > an infinite list. It's not an infinite list. It's a list of length maxBound:

Re: [Haskell-cafe] Shouldn't this loop indefinitely => take (last [0..]) [0..]

2008-04-03 Thread Don Stewart
olivier.boudry: >Hi all, > >If you compile and run this: > >main = do > putStrLn $ show $ take (last [0..]) [0..] > >or simply run: > >take (last [0..]) [0..] > >in ghci, it first hang for about one minute and then starts to generate an >infinite li

[Haskell-cafe] Shouldn't this loop indefinitely => take (last [0..]) [0..]

2008-04-03 Thread Olivier Boudry
Hi all, If you compile and run this: main = do putStrLn $ show $ take (last [0..]) [0..] or simply run: take (last [0..]) [0..] in ghci, it first hang for about one minute and then starts to generate an infinite list. I was expecting "last [0..]" to never produce a value and the

Re: [Haskell-cafe] Typing with co/contra-variance.

2008-04-03 Thread Aaron Tomb
On Apr 3, 2008, at 10:41 AM, Luke Palmer wrote: On Thu, Apr 3, 2008 at 9:58 AM, Ben Lippmeier <[EMAIL PROTECTED] > wrote: Questions: 1) Could I perhaps wave my arms around and say something about the Int in the type of isEven being in a contra-variant position? Is this what is actually ha

Re: [Haskell-cafe] Re: Role based access control via monads or arrows or... something

2008-04-03 Thread Dan Weston
Is this type-level design flexible enough for future requirement changes? The best answer to "Why is this door locked?" may not be "You don't have permission to open it", but rather "What door?". Suppose a client comes along later with a requirement that the permissions themselves are secret

[Haskell-cafe] trying to install ghc-6.8.2 both binaries and sources

2008-04-03 Thread michael
I am operating under the assumption that Idid have a broken gcc. I installed a new one This is what happened when I tried compiling ghc-6.8.2 make all /usr/bin/ghc -H16m -O -w -I. -Iinclude -Rghc-timing -ignore-package Cabal -ignore-package filepath -I../libraries -fglasgow-exts -no-recomp -c Sys

[Haskell-cafe] Re: Doing without IORef

2008-04-03 Thread Peter Hercek
Jinwoo Lee wrote: Is there any way in which I can do without IORef in tabHandler and commandLoop (written in red and bold, if you can see)? You could just always redefine the key binding for \t with a new closure which contains the updated "pwd" value (or the whole state if you like it more t

Re: [Haskell-cafe] Precedence (Part 2)

2008-04-03 Thread Gregory Collins
PR Stanley <[EMAIL PROTECTED]> writes: > Hi folks > >> let f = sum.map (^2).filter even >> f [1..4] > 20 > > So far so good! > >> sum.map (^2).filter even [1..4] > returns an error. > > How is it that the composition above as part of a function equation > doesn't return any errors while on its own

Re: [Haskell-cafe] Precedence (Part 2)

2008-04-03 Thread PR Stanley
Hi folks > let f = sum.map (^2).filter even > f [1..4] 20 So far so good! > sum.map (^2).filter even [1..4] returns an error. How is it that the composition above as part of a function equation doesn't return any errors while on its own it requires parentheses? You seem to have expression eva

Re: [Haskell-cafe] Typing with co/contra-variance.

2008-04-03 Thread Luke Palmer
On Thu, Apr 3, 2008 at 9:58 AM, Ben Lippmeier <[EMAIL PROTECTED]> wrote: > Hi all, > I have some quick questions for the type theory people: > > If I write an expression: > (if .. then 23 else "Erk") > > In Haskell this would be an error, but perhaps I can assign it the type > 'Top' (or 'Any')

Re: [Haskell-cafe] Precedence (Part 2)

2008-04-03 Thread Brandon S. Allbery KF8NH
On Apr 3, 2008, at 13:13 , PR Stanley wrote: Hi folks > let f = sum.map (^2).filter even > f [1..4] 20 So far so good! > sum.map (^2).filter even [1..4] returns an error. How is it that the composition above as part of a function equation doesn't return any errors while on its own it requi

[Haskell-cafe] Precedence (Part 2)

2008-04-03 Thread PR Stanley
Hi folks > let f = sum.map (^2).filter even > f [1..4] 20 So far so good! > sum.map (^2).filter even [1..4] returns an error. How is it that the composition above as part of a function equation doesn't return any errors while on its own it requires parentheses? I can understand the need for

Re: [Haskell-cafe] [GSoC] Porting HaRe to use the GHC API

2008-04-03 Thread Chaddaï Fouché
2008/4/1, Claus Reinke <[EMAIL PROTECTED]>: > as for the project, the are actually two APIs to consider, > GHC's and HaRe's, and the main stumbling points are those > things that are not in those APIs (explicitly or at all): > > Many thanks for the valuable insights. I intend to work in close

Re: [Haskell-cafe] installing ghc-6.8.2

2008-04-03 Thread Paulo Tanimoto
Michael, Don't the available binaries work for you? From the output it seems you are on x86, which is of course supported. The requirements are just libreadline.so.4 and libncurses.so.5. Also, if you still want to compile from source, you could grab those binaries and them to compile GHC yourse

Re: [Haskell-cafe] Doing without IORef

2008-04-03 Thread Brandon S. Allbery KF8NH
On Apr 3, 2008, at 6:03 , Jinwoo Lee wrote: Recently I wrote a code that uses readline library (System.Console.Readline). I had to maintain a state (file path) and do IO throughout the code, so I decided to use StateT monad. The problem was that in order to retrieve the current state (file

Re: [Haskell-cafe] Re: Function Precedence

2008-04-03 Thread Henning Thielemann
On Thu, 3 Apr 2008, [EMAIL PROTECTED] wrote: Fractional, Floating, etc. are also horrible. Why the square root needs to be floating? It can belong to the algebraic number domain. At least in NumericPrelude we have separated these issues. ___ Haskell

Re: [Haskell-cafe] Re: Role based access control via monads or arrows or... something

2008-04-03 Thread David Roundy
On Thu, Apr 03, 2008 at 05:31:16PM +0200, apfelmus wrote: > David Roundy wrote: > >Luke Palmer wrote: > >>porrifolius wrote: > >>> (7) ideally required permissions would appear (and accumulate) in > >>> type signatures via inference so application code knows which are > >>> required and type check

[Haskell-cafe] Re: Sorting with a weaker form of Ord (Re: Type constraints for class instances)

2008-04-03 Thread apfelmus
Krzysztof Skrzętnicki wrote: class YOrd a where ycmp :: a -> a -> (a,a) Unfortunately, the performance of ysort is rather low. I believe that it is impossible to create any sorting algorithm that uses ycmp instead of compare, that is faster than O(n^2). Ok, it is possible to be faster, n

[Haskell-cafe] Re: Role based access control via monads or arrows or... something

2008-04-03 Thread apfelmus
David Roundy wrote: Luke Palmer wrote: porrifolius wrote: (7) ideally required permissions would appear (and accumulate) in type signatures via inference so application code knows which are required and type checker can reject static/dynamic role constraint violations If you mean what I

[Haskell-cafe] Re: Typing with co/contra-variance.

2008-04-03 Thread apfelmus
Ben Lippmeier wrote: If I write an expression: (if .. then 23 else "Erk") In Haskell this would be an error, but perhaps I can assign it the type 'Top' (or 'Any') and then use reflection ala Data.Dynamic to inspect the type of this object at runtime and cast it back to something useful... c

Re: [Haskell-cafe] Re: Function Precedence

2008-04-03 Thread Hans Aberg
On 3 Apr 2008, at 16:07, Chris Smith wrote: This problem is not caused by defining f+g, but by defining numerals as constants. Yup. So the current (Num thing) is basically: 1. The type thing is a ring 2. ... with signs and absolute values 3. ... along with a natural homomorphism from Z int

[Haskell-cafe] Re: HDBC, character encoding

2008-04-03 Thread John Goerzen
On 2008-04-01, Peter Gammie <[EMAIL PROTECTED]> wrote: > On 31/03/2008, at 11:42 PM, Bjorn Bringert wrote: > >> 2008/3/26 Adrian Neumann <[EMAIL PROTECTED]>: >>> Hi, >>> >>> I wrote a CGI program to access a Postgres database using HDBC. [...] >> >> I think that Peter Gammie (copied) has some code

[Haskell-cafe] Re: Function Precedence

2008-04-03 Thread jerzy . karczmarczuk
Chris Smith writes: ... So the current (Num thing) is basically: 1. The type thing is a ring 2. ... with signs and absolute values 3. ... along with a natural homomorphism from Z into thing 4. ... and with Eq and Show. If one wanted to be perfectly formally correct, then each of 2-4 could be

Re: [Haskell-cafe] Re: Function Precedence

2008-04-03 Thread Bulat Ziganshin
Hello Chris, Thursday, April 3, 2008, 6:07:53 PM, you wrote: > On the other hand, I have enough time already trying to explain Num, > Fractional, Floating, RealFrac, ... to new haskell programmes. I'm not > sure it's an advantage if someone must learn the meaning of an additive > commutative sem

[Haskell-cafe] Re: Function Precedence

2008-04-03 Thread Chris Smith
Hans Aberg wrote: > This problem is not caused by defining f+g, but by defining numerals as > constants. Yup. So the current (Num thing) is basically: 1. The type thing is a ring 2. ... with signs and absolute values 3. ... along with a natural homomorphism from Z into thing 4. ... and with Eq a

Re: [Haskell-cafe] Role based access control via monads or arrows or... something

2008-04-03 Thread David Roundy
On Thu, Apr 03, 2008 at 12:45:49AM +, Luke Palmer wrote: > 2008/4/2 porrifolius <[EMAIL PROTECTED]>: > > (7) ideally required permissions would appear (and accumulate) in > > type signatures via inference so application code knows which are > > required and type checker can reject static/dy

[Haskell-cafe] Re: installing ghc-6.8.2

2008-04-03 Thread Christian Maeder
[EMAIL PROTECTED] wrote: > It seems there is no ghc 6.8.2 for my version of debian. So I am > compiling from source. this requires a working compiler! > /usr/bin/ghc this compiler does not work with your gcc. if you cannot install http://www.haskell.org/ghc/dist/6.8.2/ghc-6.8.2-i386-unknown-lin

Re: [Haskell-cafe] Doing without IORef

2008-04-03 Thread Claude Heiland-Allen
Jinwoo Lee wrote: Hi, Recently I wrote a code that uses readline library (System.Console.Readline). I had to maintain a state (file path) and do IO throughout the code, so I decided to use StateT monad. The problem was that in order to retrieve the current state (file path) inside the handl

Re: [Haskell-cafe] Doing without IORef

2008-04-03 Thread Alfonso Acosta
> type MyState a = StateT FilePath IO a > Is there any way in which I can do without IORef in tabHandler and > commandLoop (written in red and bold, if you can see)? How about keeping the IORef but storing it inside the state? type MySate a = StateT (IORef FilePath) IO a __

[Haskell-cafe] Doing without IORef

2008-04-03 Thread Jinwoo Lee
Hi, Recently I wrote a code that uses readline library (System.Console.Readline). I had to maintain a state (file path) and do IO throughout the code, so I decided to use StateT monad. The problem was that in order to retrieve the current state (file path) inside the handler that had been registe

[Haskell-cafe] Typing with co/contra-variance.

2008-04-03 Thread Ben Lippmeier
Hi all, I have some quick questions for the type theory people: If I write an expression: (if .. then 23 else "Erk") In Haskell this would be an error, but perhaps I can assign it the type 'Top' (or 'Any') and then use reflection ala Data.Dynamic to inspect the type of this object at runtime

Re: [Haskell-cafe] Function Precedence

2008-04-03 Thread Hans Aberg
On 3 Apr 2008, at 08:07, Henning Thielemann wrote: Show could be implemented by writing out the function closures, but I think the reason it is not there is that it would create overhead in compiled code. It would also not give referential transparent answers, because the same function can

Re: [Haskell-cafe] Function Precedence

2008-04-03 Thread Hans Aberg
On 3 Apr 2008, at 07:59, Henning Thielemann wrote: But one should also be able to write (f+g)(x). - This does not work in Haskell, because Num requires an instance of Eq and Show. You could define these instances with undefined function implementations anyway. But also in a more cleaner type