Re: [Haskell-cafe] Type class help please

2007-05-15 Thread Brandon S. Allbery KF8NH
On May 16, 2007, at 0:57 , Adrian Hey wrote: -- GT class -- class Ord key => GT map key | map -> key where assocsAscending :: map a -> [(key,a)] -- Just 1 of many methods -- Instances of GT are instances of Eq -- Instances of Ord are instances of Eq, so defining your own instance Eq for a

[Haskell-cafe] Type class help please

2007-05-15 Thread Adrian Hey
Hello, Here's a simple module I'm playing about with.. {-# OPTIONS_GHC -fglasgow-exts #-} module Test(GT(..)) where -- GT class -- class Ord key => GT map key | map -> key where assocsAscending :: map a -> [(key,a)] -- Just 1 of many methods -- Instances of GT are instances of Eq -- instance

Re: [Haskell-cafe] Converting CTime -> Int

2007-05-15 Thread Brandon S. Allbery KF8NH
On May 16, 2007, at 0:37 , Stefan O'Rear wrote: On Tue, May 15, 2007 at 11:35:52PM -0500, Rob Hoelz wrote: I've poured over the standard library docs, but to no avail. Could someone give me a hint? fromIntegral No instance for (Integral CTime) arising from a use of `fromIntegral

Re: [Haskell-cafe] Converting CTime -> Int

2007-05-15 Thread Brandon S. Allbery KF8NH
On May 16, 2007, at 0:35 , Rob Hoelz wrote: wrapping returns time_t. I see that this maps to CTime in Foreign.C.Types, but I can't figure out how to convert it to an Int (or any other useful Haskell type, for that matter) for the life of me. I've poured over the standard library docs, but t

Re: [Haskell-cafe] Converting CTime -> Int

2007-05-15 Thread Stefan O'Rear
On Tue, May 15, 2007 at 11:35:52PM -0500, Rob Hoelz wrote: > Hello everyone, > > I'm writing an interface to C code, and one of the functions I'm > wrapping returns time_t. I see that this maps to CTime in > Foreign.C.Types, but I can't figure out how to convert it to an Int (or > any other usefu

[Haskell-cafe] Converting CTime -> Int

2007-05-15 Thread Rob Hoelz
Hello everyone, I'm writing an interface to C code, and one of the functions I'm wrapping returns time_t. I see that this maps to CTime in Foreign.C.Types, but I can't figure out how to convert it to an Int (or any other useful Haskell type, for that matter) for the life of me. I've poured over t

Re: [Haskell-cafe] Higher order types via the Curry-Howard correspondence

2007-05-15 Thread Stefan O'Rear
On Tue, May 15, 2007 at 07:44:25PM -0700, Stefan O'Rear wrote: > λ(el : *). ∀(res : *). (∀(seed : *). seed → (seed → el) → (seed → seed) → res) that little decoding error at the end should have been -> res. I need a better unicode editing solution :) Stefan __

Re: [Haskell-cafe] Higher order types via the Curry-Howard correspondence

2007-05-15 Thread Stefan O'Rear
On Tue, May 15, 2007 at 10:28:08PM -0400, Scott Turner wrote: > On 2007 May 13 Sunday 14:52, Benja Fallenstein wrote: > > 2007/5/12, Derek Elkins <[EMAIL PROTECTED]>: > > > In Haskell codata and data coincide, but if you want consistency, that > > > cannot be the case. > > > > For fun and to see wh

Re: [Haskell-cafe] Higher order types via the Curry-Howard correspondence

2007-05-15 Thread Scott Turner
On 2007 May 13 Sunday 14:52, Benja Fallenstein wrote: > 2007/5/12, Derek Elkins <[EMAIL PROTECTED]>: > > In Haskell codata and data coincide, but if you want consistency, that > > cannot be the case. > > For fun and to see what you have to avoid, here's the proof of Curry's > paradox, using weird i

Re: [Haskell-cafe] problem with implicit parameter

2007-05-15 Thread Dan Mead
try sticking a semicolon in there for good measure, sometimes ghc gets confused On 5/15/07, Eric <[EMAIL PROTECTED]> wrote: Hi there, I've written the following program putchr = putChar ?d main = do { c <- getChar ; putchr with ?d = c} which I try to compile with ghc --make -fimplicit-para

Re: [Haskell-cafe] Re: The danger of Monad ((->) r)

2007-05-15 Thread Bjorn Bringert
On May 15, 2007, at 14:52 , Tomasz Zielonka wrote: On Tue, May 15, 2007 at 02:27:13PM +0200, Arie Peterson wrote: Hi Tomek! Hi! Have you considered changing the statements to have type 'ReaderT Database IO ()'? Then (>>) actually does what you want. I tried it and it made the code simp

Re: [Haskell-cafe] Re: ANNOUNCE: Harpy -- run-time code generation library

2007-05-15 Thread Dirk Kleeblatt
apfelmus wrote: Dirk Kleeblatt wrote: apfelmus wrote: [...] So, yes, the code position is only used after the definition of the label. But the "look up in a map"-part makes the jmp operation strict in the label parameter. Ah, I slowly get what you mean. In short, the point is that you're rei

[Haskell-cafe] problem with implicit parameter

2007-05-15 Thread Eric
Hi there, I've written the following program putchr = putChar ?d main = do { c <- getChar ; putchr with ?d = c} which I try to compile with ghc --make -fimplicit-params myprogram However I keep getting the following error: myprogram.hs:5:17: parse error on input `=' What's wrong? E. __

Re: [Haskell-cafe] openBinaryFile

2007-05-15 Thread Jules Bean
Eric wrote: Hello all, Does anyone have some sample code for reading and writing to binary files? openBinaryFile is a bit of a red herring. All it does is disable the line-ending interpretation which may or may not happen on some OSes when you open a file in text mode. For simple binary

[Haskell-cafe] openBinaryFile

2007-05-15 Thread Eric
Hello all, Does anyone have some sample code for reading and writing to binary files? E. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] readline crashes in Emacs buffer on Windows

2007-05-15 Thread Gleb Alexeyev
Hello Cafe! I asked about this problem on IRC channel but with little luck. The problem boils down to the following: readline crashes on any input if the calling program runs in the Emacs buffer. To reproduce this bug, load the code below into ghci using haskell-mode and run main. >import Sys

Re: [Haskell-cafe] Re: The danger of Monad ((->) r)

2007-05-15 Thread Conal Elliott
You could also use mappend instead of concatStmts and keep the Database -> IO () representation.- Conal On 5/15/07, Arie Peterson <[EMAIL PROTECTED]> wrote: Hi Tomek! > In a CGI application I was gathering SQL statements I wanted to run in > the final transaction. Because I use haskelldb,

[Haskell-cafe] Re: Problem with finalizers

2007-05-15 Thread Ivan Tomac
Hi Simon, On 15/05/2007, at 8:31 PM, Simon Marlow wrote: There is no guarantee that a finalizer will be run before your program exits. The only thing you can be sure of is that it will *not* run while the ForeignPtr is still reachable by the garbage collector. In practice GHC will schedul

Re: [Haskell-cafe] Re: The danger of Monad ((->) r)

2007-05-15 Thread Tomasz Zielonka
On Tue, May 15, 2007 at 02:27:13PM +0200, Arie Peterson wrote: > Hi Tomek! Hi! > Have you considered changing the statements to have type 'ReaderT Database > IO ()'? Then (>>) actually does what you want. I tried it and it made the code simpler, more readable and of course more immune to this ty

[Haskell-cafe] Re: The danger of Monad ((->) r)

2007-05-15 Thread Arie Peterson
Hi Tomek! > In a CGI application I was gathering SQL statements I wanted to run in > the final transaction. Because I use haskelldb, it was most convenient > to use (Database -> IO ()) as the type of the statement or a group of > statements. In this representation concatenating two statement grou

[Haskell-cafe] Re: Problem with finalizers

2007-05-15 Thread Simon Marlow
Ivan Tomac wrote: It appears that if I add import Control.Concurrent and call yield just after performGC then the finalizer does get called. But it only seems to work if I call both performGC and yield and in that order. There is no guarantee that a finalizer will be run before your program

Re: [Haskell-cafe] The danger of not specifying types (was The danger of Monad ((->) r))

2007-05-15 Thread Tomasz Zielonka
On Tue, May 15, 2007 at 11:15:20AM +0100, Jules Bean wrote: > Tomasz Zielonka wrote: > >My mistake was that I forgot about db and wrote: > > > >concatStmts s1 s2 = s1 >> s2 > > > >And it was accepted because I had the Monad instance for ((->) r) in > >scope (from Control.Monad.Trans I guess)! >

Re: [Haskell-cafe] The danger of not specifying types (was The danger of Monad ((->) r))

2007-05-15 Thread Jules Bean
Tomasz Zielonka wrote: My mistake was that I forgot about db and wrote: concatStmts s1 s2 = s1 >> s2 And it was accepted because I had the Monad instance for ((->) r) in scope (from Control.Monad.Trans I guess)! The danger in overloading is that you are relying on the compiler to infe

[Haskell-cafe] The danger of Monad ((->) r)

2007-05-15 Thread Tomasz Zielonka
Hello! In a CGI application I was gathering SQL statements I wanted to run in the final transaction. Because I use haskelldb, it was most convenient to use (Database -> IO ()) as the type of the statement or a group of statements. In this representation concatenating two statement groups so they a

Re: [Haskell-cafe] Code layout in Emacs' haskell-mode

2007-05-15 Thread Jules Bean
Christopher L Conway wrote: I've installed 2.3 and it exhibits the same indentation behavior: any entity appearing on a new line immediately after "module X where" wants to be indented 4 spaces, including function definitions and variable bindings. Yes, it does do that. And it's correct syntax