Re: [Haskell-cafe] Best way to build strings?

2005-07-20 Thread Bernard Pope
On Wed, 2005-07-20 at 17:06 +0100, Andy Gimblett wrote: > A small stylistic question: what's the "best" way to build strings > containing other values? For example, I have: > > data Process = Stop | >Prefix String Process | >External Process Process > > instance S

Re: [Haskell-cafe] Updating the Haskell Standard

2005-07-20 Thread Fergus Henderson
On 20-Jul-2005, David Barton <[EMAIL PROTECTED]> wrote: > I can contribute some experience from commercial standardization efforts. > ANSI, IEEE, and ISO standards require re-ballotting every five years, > otherwise the standards lapse. Reballotting may or may not be accompanied > by changes in

RE: [Haskell-cafe] Re: FFI and callbacks

2005-07-20 Thread Simon Marlow
On 20 July 2005 18:49, John Goerzen wrote: > On 2005-07-20, Simon Marlow <[EMAIL PROTECTED]> wrote: >> This paper might help shed some light: >> >> http://www.haskell.org/~simonmar/papers/conc-ffi.pdf > > Forgot to reply to this. *Very helpful* link, I had always wondered > what the bound thre

Re: [Haskell-cafe] Updating the Haskell Standard

2005-07-20 Thread David Barton
John Goerzen writes: There was a brief discussion on #haskell today about the Haskell standard. I'd like to get opinions from more people, and ask if there is any effort being done in this direction presently. I know that some people would like to hold off on such a process until their fav

[Haskell-cafe] Updating the Haskell Standard

2005-07-20 Thread John Goerzen
There was a brief discussion on #haskell today about the Haskell standard. I'd like to get opinions from more people, and ask if there is any effort being done in this direction presently. I think an updated standard is overdue. I find it difficult anymore to write any but the most trivial of pr

[Haskell-cafe] Re: FFI and callbacks

2005-07-20 Thread John Goerzen
On 2005-07-20, Simon Marlow <[EMAIL PROTECTED]> wrote: > This paper might help shed some light: > > http://www.haskell.org/~simonmar/papers/conc-ffi.pdf Forgot to reply to this. *Very helpful* link, I had always wondered what the bound thread functions in Control.Concurrent were for :-) So let

Re: [Haskell-cafe] Best way to build strings?

2005-07-20 Thread Tomasz Zielonka
On Wed, Jul 20, 2005 at 07:00:22PM +0200, Lemmih wrote: > On 7/20/05, Andy Gimblett <[EMAIL PROTECTED]> wrote: > > > > Is there a facility like this in Haskell? Or something else I should > > be using, other than lots of ++ ? > > There's Text.Printf: > > Prelude Text.Printf> printf "(%s [] %s)"

[Haskell-cafe] Re: FFI and callbacks

2005-07-20 Thread John Goerzen
On 2005-07-20, Simon Marlow <[EMAIL PROTECTED]> wrote: > You could forkIO the main loop if you want; it shouldn't make any > difference, except that GHC terminates the program when the main thread > completes, so it's more convenient to have the main loop run in the main > thread, so that the progr

Re: [Haskell-cafe] Best way to build strings?

2005-07-20 Thread Lemmih
On 7/20/05, Andy Gimblett <[EMAIL PROTECTED]> wrote: > A small stylistic question: what's the "best" way to build strings > containing other values? For example, I have: > > data Process = Stop | >Prefix String Process | >External Process Process > > instance Show

Re: [Haskell-cafe] Best way to build strings?

2005-07-20 Thread Frank-Andre Riess
Hello there, > I'm very fond of Python's interpolation approach, where we'd have > something like the following for the External case: > >     def __str__(self): >         return "(%s [] %s)" % (self.p, self.q) are you familiar with C's printf procedure? It's where that kind of notation comes fr

Re: [Haskell-cafe] Best way to build strings?

2005-07-20 Thread Bryn Keller
How about this? instance Show Process where show Stop = "Stop" show (Prefix l p) = concat ["(", l, "->", show p, ")"] show (External p q) = concat ["(", show p, " [] ", show q, ")"] Hope that helps, Bryn Andy Gimblett wrote: A small stylistic question: what's the "best" way to buil

Re: [Haskell-cafe] file line operation perhaps need loop

2005-07-20 Thread Benjamin Franksen
On Wednesday 20 July 2005 08:27, Sun Yi Ming wrote: > Hello, > I have two txt file,and i want to mix the two files line by line, > [...] > import System.IO > > mix :: [a] -> [a] -> [a] > mix [] ys = ys > mix xs [] = xs > mix (x:xs) (y:ys) = [x,y] ++ mix xs ys > > f1 = do contents1 <- readFile "ur

Re: [Haskell-cafe] How to parsing files

2005-07-20 Thread Henning Thielemann
On Wed, 20 Jul 2005, Jake Luck wrote: > > I need to parse a file in this format: > > float float float > > float float float > > Each row has 3-columns of floating procision number divided by white > > space. The number of lines is undefined. I use (lines (readFile "...")) > > to read the fil

Re: [Haskell-cafe] How to parsing files

2005-07-20 Thread Jake Luck
I need to parse a file in this format: float float float float float float Each row has 3-columns of floating procision number divided by white space. The number of lines is undefined. I use (lines (readFile "...")) to read the file. Text.ParserCombinators.Parsec sounds perfect, no? _

[Haskell-cafe] Best way to build strings?

2005-07-20 Thread Andy Gimblett
A small stylistic question: what's the "best" way to build strings containing other values? For example, I have: data Process = Stop | Prefix String Process | External Process Process instance Show Process where show Stop = "Stop" show (Prefix l p) = "(" ++

RE: [Haskell-cafe] FFI and callbacks

2005-07-20 Thread Simon Marlow
On 20 July 2005 16:23, John Goerzen wrote: > On Wed, Jul 20, 2005 at 04:10:38PM +0100, Simon Marlow wrote: >> On 20 July 2005 14:35, John Goerzen wrote: >>> These systems generally have some sort of an opaque main loop, >>> implemented in C. This loop would usually never return, or perhaps >>> on

Re: [Haskell-cafe] FFI and callbacks

2005-07-20 Thread John Goerzen
On Wed, Jul 20, 2005 at 04:10:38PM +0100, Simon Marlow wrote: > On 20 July 2005 14:35, John Goerzen wrote: > > These systems generally have some sort of an opaque main loop, > > implemented in C. This loop would usually never return, or perhaps > > only return once the UI is destroyed. > > Is the

RE: [Haskell-cafe] FFI and callbacks

2005-07-20 Thread Simon Marlow
On 20 July 2005 14:35, John Goerzen wrote: > I'm looking at packaging an event-driven console widget set (CDK) for > Haskell using FFI. I know that other event-driven widget sets have > Haskell bindings, but I'm not quite sure how to make everything play > nice with forkIO. > > These systems gen

Re[2]: [Haskell-cafe] matrix computations based on the GSL

2005-07-20 Thread Bulat Ziganshin
Hello Alberto, Tuesday, July 19, 2005, 5:11:27 PM, you wrote: AR> Hello Bulat, thanks a lot for your message, the RULES pragma is just what we AR> need! AR> However, in some initial experiments I have observed some strange behavior. AR> For instance, in the following program: 1) there is no guar

Re: [Haskell-cafe] Named data type members

2005-07-20 Thread Bulat Ziganshin
Hello yin, Wednesday, July 20, 2005, 1:18:25 AM, you wrote: y> data SomeData = y> SomeData { y> int1 :: Int, y> int2 :: Int y> } y> class SomeClass where y>infix 1 `i_` y>i_ :: SomeData -> Int -> SomeData y>infix 1 `_i` y

RE: [Haskell-cafe] FFI and callbacks

2005-07-20 Thread Bayley, Alistair
> From: John Goerzen [mailto:[EMAIL PROTECTED] > > How would I make this sort of system play nice with Haskell threads? > > Also, the brief FFI docs that I've found don't really explain > callbacks > in FFI very well to me. Are there any other resources on > this anywhere? This might help:

[Haskell-cafe] FFI and callbacks

2005-07-20 Thread John Goerzen
Hi, I'm looking at packaging an event-driven console widget set (CDK) for Haskell using FFI. I know that other event-driven widget sets have Haskell bindings, but I'm not quite sure how to make everything play nice with forkIO. These systems generally have some sort of an opaque main loop, imple

Re: [Haskell-cafe] Word32 to Int converions

2005-07-20 Thread Mark Carroll
On Wed, 20 Jul 2005, yin wrote: > Bernard Pope wrote: > > >On Wed, 2005-07-20 at 11:43 +0200, yin wrote: > > > >> > >>how do I convert an Word32 (or WordXYZ) to Int, or Integer, or Float, > >>...? The Int conversion is the priority. > >> > >> > >fromIntegral to convert to an instance of Integral,

[Haskell-cafe] How to parsing files

2005-07-20 Thread yin
Hi, I need to parse a file in this format: float float float float float float Each row has 3-columns of floating procision number divided by white space. The number of lines is undefined. I use (lines (readFile "...")) to read the file. Thnks. Matej 'Yin' Gagyi

RE: [Haskell-cafe] Strict and non-strict vs eager and lazy, was Confused about Cyclic struture

2005-07-20 Thread Simon Marlow
On 18 July 2005 15:19, Bayley, Alistair wrote: > Not a taker (yet - where can I find information about non-lazy > implementation of non-strict languages? From Google so far: > speculative evaluation (Eager Haskell), call-by-name vs call-by-need.) > > Wikipedia frustratingly hints that "other eval

Re: [Haskell-cafe] Haskell, SDL, OpenGL

2005-07-20 Thread Lemmih
On 7/20/05, Sven Panne <[EMAIL PROTECTED]> wrote: > Am Montag, 18. Juli 2005 18:46 schrieb yin: > > [...] > > ld-options: -L/usr/lib -Wl -rpath /usr/lib -lSDL > > This looks a bit suspicious: The syntax for ld options is "-rpath DIR", so the > option for gcc should be "-Wl,-rpath,DIR". Ugly, but I

Re: [Haskell-cafe] Word32 to Int converions

2005-07-20 Thread yin
Bernard Pope wrote: >On Wed, 2005-07-20 at 11:43 +0200, yin wrote: > >> >>how do I convert an Word32 (or WordXYZ) to Int, or Integer, or Float, >>...? The Int conversion is the priority. >> >> >fromIntegral to convert to an instance of Integral, such as Int, Integer >etc > Thank you, but how t

Re: [Haskell-cafe] file line operation perhaps need loop

2005-07-20 Thread Sun Yi Ming
Arthur van Leeuwen <[EMAIL PROTECTED]> worte: > Ah, but this is exactly where lazyness wins bigtime: a smart > implementation > of readFile will lazily read the actual file for as far as needed. Thus, > reading with readFile will not read the entire file into memory at once. > What will happen is t

Re: [Haskell-cafe] file line operation perhaps need loop

2005-07-20 Thread Henning Thielemann
On Wed, 20 Jul 2005, Sun Yi Ming wrote: > mix :: [a] -> [a] -> [a] > mix [] ys = ys > mix xs [] = xs > mix (x:xs) (y:ys) = [x,y] ++ mix xs ys mix xs ys = concat (Data.List.transpose [xs,ys]) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http:

Re: [Haskell-cafe] Word32 to Int converions

2005-07-20 Thread Bernard Pope
On Wed, 2005-07-20 at 11:43 +0200, yin wrote: > hello, > > how do I convert an Word32 (or WordXYZ) to Int, or Integer, or Float, > ...? The Int conversion is the priority. > > Thanks. > > Matej 'Yin' Gagyi fromIntegral to convert to an instance of Integral, such as Int, Integer etc Cheers, Ber

Re: [Haskell-cafe] Error with Float

2005-07-20 Thread Dinh Tien Tuan Anh
To get exact fractions, use the Ratio module (import Ratio) and the Rational type which is defined there. Thanks dude, it works The code you wrote below has a serious style problem that I thought I'd point out: you shouldn't use the IO monad for pure functions. I've never known that, th

[Haskell-cafe] Word32 to Int converions

2005-07-20 Thread yin
hello, how do I convert an Word32 (or WordXYZ) to Int, or Integer, or Float, ...? The Int conversion is the priority. Thanks. Matej 'Yin' Gagyi ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] file line operation perhaps need loop

2005-07-20 Thread Bernard Pope
On Wed, 2005-07-20 at 14:27 +0800, Sun Yi Ming wrote: [snip] > i first write this snippet of code: > --- > import System.IO > > mix :: [a] -> [a] -> [a] > mix [] ys = ys > mix xs [] = xs > mix (x:xs) (y:ys) = [x,y] ++ mix xs ys > > f1 = do contents1 <- readFile "url1.txt" > content

Re: [Haskell-cafe] Haskell, SDL, OpenGL

2005-07-20 Thread Sven Panne
Am Montag, 18. Juli 2005 18:46 schrieb yin: > [...] > ld-options: -L/usr/lib -Wl -rpath /usr/lib -lSDL This looks a bit suspicious: The syntax for ld options is "-rpath DIR", so the option for gcc should be "-Wl,-rpath,DIR". Ugly, but I didn't invent that. :-) Furthermore, I've never seen a Linu

Re: [Haskell-cafe] file line operation perhaps need loop

2005-07-20 Thread Arthur van Leeuwen
On Wed, Jul 20, 2005 at 02:27:36PM +0800, Sun Yi Ming wrote: > Hello, > I have two txt file,and i want to mix the two files line by line, e.g. > $ cat url1.txt >url1_1.line >url1_2.line > $ cat url2.txt >url2_1.line >url2_2.line > and i want this file as result: > $ cat aha.tx

Re: [Haskell-cafe] file line operation perhaps need loop

2005-07-20 Thread yin
Sun Yi Ming wrote: > Hello, Hello, > this works fine, but i think if the two file are very big, and the > readFile will consume too many mem.so i need to read the file line by > line but stunned by the loop in IO Monad: > > main = do h1 <- openFile "url1.txt" ReadMode > h2 <- openFile "url2.txt"