[Haskell-cafe] Socket Programming

2006-12-30 Thread Mark Goldman
I am trying to write a toy echo server that can handle multiple connections. I would like to be able to test and see if there are any connections waiting to be accepted on a socket. In C and related languages I would use something like select or poll to be nice to the OS, what would I use with t

Re: [Haskell-cafe] Re: HaXML - creating a simple document

2006-12-30 Thread Terrence Brannon
Actually, the examples directory in the distro for the development release has a nice program to create an element and print it to stdout called SimpleTestBool.hs: module Main where import List (isPrefixOf) import Text.XML.HaXml.XmlContent import Text.XML.HaXml.Types import Text.PrettyPrint.Hugh

[Haskell-cafe] Re: HaXML - creating a simple document

2006-12-30 Thread Terrence Brannon
On 12/30/06, Jeremy Shaw < [EMAIL PROTECTED]> wrote: So may something like this would work: > main = print $ htmlprint $ go (CString False "") mk.hs:6:33: Couldn't match expected type `Content i' against inferred type `i1 -> Content i1' In the first argument of `

Re: [Haskell-cafe] HaXML - creating a simple document

2006-12-30 Thread Jeremy Shaw
Hello, According to this page: http://www.cs.york.ac.uk/fp/HaXml/HaXml/Text-XML-HaXml-Wrappers.html processXmlWith is used to apply a filter to an existing XML document. By default, it will try to read the input document from stdin. So, I am imagine that is what it is doing -- sitting their wait

[Haskell-cafe] HaXML - creating a simple document

2006-12-30 Thread Terrence Brannon
Hello, I don't know why my simple example will not render a simple HTML document. For the moment, I simply want to render this: or whatever, the simplest document is. When I run my source code, it simply hangs (as the transcript below shows) {- SOURCE CODE -} import Text.XML.HaXml.Html.Gener

Re: [Haskell-cafe] Re: Seeking advice on a style question

2006-12-30 Thread Steve Schafer
On Fri, 29 Dec 2006 21:01:31 +0100, you wrote: >>> process :: Item -> MediaKind -> MediaSize -> Language -> SFO >"Item" doesn't tell me anything. Seems to be an XML-File containing the >questions and such. The reason it's just "Item" is that it can be a number of different things. It can be a ful

Re: [Haskell-cafe] Seeking advice on a style question

2006-12-30 Thread Steve Schafer
On Fri, 29 Dec 2006 18:39:04 +0100, you wrote: >Why not generate Haskell code from such a graph? Well, that would indeed be a workable solution. But I don't have quite the resources to design Yet Another Visual Programming Language. And a textual representation of the graph would have exactly th

Re: Re[4]: [Haskell-cafe] Strange type behavior in GHCi 6.4.2

2006-12-30 Thread Kirsten Chevalier
On 12/30/06, Grady Lemoine <[EMAIL PROTECTED]> wrote: I tried compiling, but I got a linker error: /usr/lib/ghc-6.4.2/libHSrts.a(Main.o): In function `main': (.text+0x2): undefined reference to `__stginit_ZCMain' /usr/lib/ghc-6.4.2/libHSrts.a(Main.o): In function `main': (.text+0x16): undefined

Re: Re[4]: [Haskell-cafe] Strange type behavior in GHCi 6.4.2

2006-12-30 Thread Grady Lemoine
I tried compiling, but I got a linker error: /usr/lib/ghc-6.4.2/libHSrts.a(Main.o): In function `main': (.text+0x2): undefined reference to `__stginit_ZCMain' /usr/lib/ghc-6.4.2/libHSrts.a(Main.o): In function `main': (.text+0x16): undefined reference to `ZCMain_main_closure' collect2: ld returne

Re: [Haskell-cafe] Literate Haskell source files. How do I turn them into something I can read?

2006-12-30 Thread Tony Finch
On Sat, 30 Dec 2006, Michael T. Richter wrote: > Apparently the GHC compiler can take .lhs files, strip them with "unlit" > (a utility which I finally found buried deep in the GHC installation -- > off-path) and then compile them normally. The problem I have is that > unlit leaves behind instead

Re: [Haskell-cafe] Mo' comprehensions

2006-12-30 Thread Neil Mitchell
Hi I was solving some programming puzzles today[1], and found myself pining for Map comprehensions. [ ... (key,val) <- fromList map, ... ] It isn't really that much more than a straight comprehension would be on a map. By default should a map comprehension let you inspect the values, or the

Re: [Haskell-cafe] Mo' comprehensions

2006-12-30 Thread Lennart Augustsson
What would the Comprehensible class have? And how would it be different from Monad(Zero)? -- Lennart On Dec 30, 2006, at 10:05 , Diego Navarro wrote: I was solving some programming puzzles today[1], and found myself pining for Map comprehensions. Maybe there should be a Comprehensibl

Re: [Haskell-cafe] Literate Haskell source files. How do I turn them into something I can read?

2006-12-30 Thread Kirsten Chevalier
On 12/29/06, Michael T. Richter <[EMAIL PROTECTED]> wrote: I'm trying to wrap my mind around the darcs source code as a preliminary to looking into GHC's guts. All of darcs is written as .lhs files which have bizarre mark-up in them which distracts me from the actual Haskell source I'm tryin

Re: Re[4]: [Haskell-cafe] Strange type behavior in GHCi 6.4.2

2006-12-30 Thread Kirsten Chevalier
On 12/30/06, Bulat Ziganshin <[EMAIL PROTECTED]> wrote: Hello Kirsten, Friday, December 29, 2006, 6:30:22 PM, you wrote: > I suggest *not* using these pragmas unless a combination of profiling > and reading intermediate code dumps suggests that foo -- and its > un-specialized nature -- is truly

[Haskell-cafe] Mo' comprehensions

2006-12-30 Thread Diego Navarro
I was solving some programming puzzles today[1], and found myself pining for Map comprehensions. Maybe there should be a Comprehensible class that's automatically mapped to comprehension syntax. It's rather odd to have them only for lists. That would be both more general and more elegant than jus

Re: Re[4]: [Haskell-cafe] Strange type behavior in GHCi 6.4.2

2006-12-30 Thread Lennart Augustsson
Maybe it's simpler to add a lot of INLINE, but that can make a program slower as well as faster. It's much better to profile and add them where they are needed. -- Lennart On Dec 30, 2006, at 08:42 , Bulat Ziganshin wrote: Hello Kirsten, Friday, December 29, 2006, 6:30:22 PM, you wro

Re[4]: [Haskell-cafe] Strange type behavior in GHCi 6.4.2

2006-12-30 Thread Bulat Ziganshin
Hello Grady, Friday, December 29, 2006, 11:00:42 PM, you wrote: > I've performed some experiments in GHCi, and it looks like even for a > get essentially the same execution times no matter which of the > definitions below I use you should compare ghc -O2 times, ghci is very different beast. and

Re[4]: [Haskell-cafe] Re: Seeking advice on a style question

2006-12-30 Thread Bulat Ziganshin
Hello Steve, Friday, December 29, 2006, 8:10:29 PM, you wrote: >>it force you to give names to intermediate results which is considered as >>good programing style - program becomes more documented. > But that would imply that function composition and in-line function > definition are also Bad St

Re[4]: [Haskell-cafe] Strange type behavior in GHCi 6.4.2

2006-12-30 Thread Bulat Ziganshin
Hello Kirsten, Friday, December 29, 2006, 6:30:22 PM, you wrote: > I suggest *not* using these pragmas unless a combination of profiling > and reading intermediate code dumps suggests that foo -- and its > un-specialized nature -- is truly a bottleneck. it's a matter of taste - and experience. m

[Haskell-cafe] Re: Idiomatic Haskell equivalent of "keyword arguments" to functions

2006-12-30 Thread Jón Fairbairn
"Neil Mitchell" <[EMAIL PROTECTED]> writes: > > To make things concrete, the example I'm really thinking of is a "send > > an email" function, which would take a subject, a body, a list of > > recipients, optional lists of cc and bcc recipients, an optional > > mailserver (default localhost), an o

Re: [Haskell-cafe] Literate Haskell source files. How do I turn them into something I can read?

2006-12-30 Thread Neil Mitchell
Hi Michael, cpphs is the answer: http://www.cs.york.ac.uk/fp/cpphs/ It has a --unlit mode, and if one of the other flags doesn't remove the various forms of line dropping, I'm sure if you posted what you need doing, contacted the author or submitted a patch that someone would be able to do it. I

Re: [Haskell-cafe] how unsafe is this?

2006-12-30 Thread Donald Bruce Stewart
benc: > > I've defined a helper function to let me do regexps in functional style: > > > sed exp str = unsafePerformIO $ do > > regexp <- regcomp exp 0 > > regexec regexp str > > Is this always safe? or where is it not? > > (I'm using any one regexp more than once so it doesn't bother me that

[Haskell-cafe] how unsafe is this?

2006-12-30 Thread Ben Clifford
I've defined a helper function to let me do regexps in functional style: > sed exp str = unsafePerformIO $ do > regexp <- regcomp exp 0 > regexec regexp str Is this always safe? or where is it not? (I'm using any one regexp more than once so it doesn't bother me that it compiles each time)