[Haskell-cafe] Inferred type is not general enough

2004-07-07 Thread Ivan Tihonov
I start some ip networks related work in haskell and wrote two basic classes Location and Packet. Before writing IpLocation and IpPacket instances i have written simple TestLocation and TestPacket instances just to compile this and check for errors in class definitions. But looks like i misunde

Re: [Haskell-cafe] Folding function composition: L or R?

2004-07-07 Thread Graham Klyne
At 14:24 07/07/04 +0200, Henning Thielemann wrote: On Wed, 7 Jul 2004, Graham Klyne wrote: > [[ > sss :: [ShowS] > sss = map (++) ["abc","def","ghi","jkl"] > > ssr = foldr (.) id sss > ssl = foldl (.) id sss > > sr = ssr "" > sl = ssl "" > > -- sl == sr == "abcdefghijkl" > -- is there any efficienc

Re: [Haskell-cafe] Folding function composition: L or R?

2004-07-07 Thread Henning Thielemann
On Wed, 7 Jul 2004, Graham Klyne wrote: > [[ > sss :: [ShowS] > sss = map (++) ["abc","def","ghi","jkl"] > > ssr = foldr (.) id sss > ssl = foldl (.) id sss > > sr = ssr "" > sl = ssl "" > > -- sl == sr == "abcdefghijkl" > -- is there any efficiency difference? > ]] > > Conventional wisdom su

[Haskell-cafe] Folding function composition: L or R?

2004-07-07 Thread Graham Klyne
I have a sequence of functions that I wish to fold together using function composition (.). Does it matter if I use foldl or foldr? e.g. [[ sss :: [ShowS] sss = map (++) ["abc","def","ghi","jkl"] ssr = foldr (.) id sss ssl = foldl (.) id sss sr = ssr "" sl = ssl "" -- sl == sr == "abcdefghijkl"

RE: [Haskell-cafe] readMVar and the devils

2004-07-07 Thread Simon Marlow
On 06 July 2004 11:29, Conor T McBride wrote: > OK, here's what I want, what I do with it, and my attempt to deliver > it. But I'm not an expert, so please let me know if there's some > disastrous flaw... > > The signature/spec: > > type Hole x > > hole :: IO (Hole x) >-- returns a fresh em

Re: [Haskell-cafe] Re: Roman Numerals and Haskell Syntax abuse

2004-07-07 Thread Kent Karlsson
> now 134 > roman=(!6);n!a|n<1=""|n>=t=s!!a:(n-t)!a|c>=t=s!!(2*e):c!a|1>0=n!(a-1)where(d,m)=a`divMod`2;e=d+m-1;s="ivxlcdm";c=10^e+n;t=10^d*(1+4*m) Gosh! Anyway, you missed the roman symbols for 5000 (U+2181) and 1 (U+2182)... ;-) The ones for 5 and 10 aren't in Unicode yet, nor is th

Re: [Haskell-cafe] readMVar and the devils

2004-07-07 Thread Conor T McBride
Hi folks I had a bit more of a play over the weekend. Got addicted. Lumps of code further on down. Jan-Willem Maessen wrote: >If you're really using MVars in write-once read-many style, the >semantics of readMVar shouldn't be a problem: > >* Before the initializing write, all calls to readMVar bloc

Re: [Haskell-cafe] Of types and constructors; a question of programming style

2004-07-07 Thread Graham Klyne
At 10:23 06/07/04 -0400, Scott Turner wrote: On 2004 July 06 Tuesday 05:35, Graham Klyne wrote: > When I'm designing datatypes for a Haskell program, I sometimes seem to end > up with a slightly incoherent mixture of algebraic types and > constructors. > example > data Event = Document DocURI Eleme

[Haskell-cafe] problem with hsql on windows

2004-07-07 Thread Shanon Fernald
I'm using: GHC 6.2.1 HSQL 1.4 on a Windows XP machine. I'm trying to the compile the HSQL example using the eclipse Haskell plug-in, but I get the following error message: Chasing modules from: Main.hs Compiling Queries ( ./Queries.hs, C:\workspace\dbtest\out/Queries.o ) ./Queries.hs:3