Re: [Haskell-cafe] Ensuring Type Class instances follow the 'rules'

2009-05-28 Thread Eugene Kirpichov
Use QuickCheck. 2009/5/29 Hemanth Kapila : > Hi all, > Recently, I participated in a coding competition. > As part of it, I had to write a program wherein I had to make my data-type > an instance of Ord. An error in my implementation of compare resulted in me > losing quite a bit of  valuable time

[Haskell-cafe] Ensuring Type Class instances follow the 'rules'

2009-05-28 Thread Hemanth Kapila
Hi all, Recently, I participated in a coding competition. As part of it, I had to write a program wherein I had to make my data-type an instance of Ord. An error in my implementation of compare resulted in me losing quite a bit of valuable time. As I wrote it, I had tested it out on the ghci and

Re: [Haskell-cafe] What's the problem with iota's type signature?

2009-05-28 Thread michael rice
And I thought everyone was puzzling these type signatures out all by themselves. ;-) The Haskell learning curve is about the steepest I've ever seen for a computer language, but I think I'm catching on. Thanks for the info. Michael --- On Thu, 5/28/09, wren ng thornton wrote: From: wren ng

Re: [Haskell-cafe] Problem w/YAHT code example

2009-05-28 Thread michael rice
Thanks! I just copied the code from the PDF file. Whatever that character was it wasn't the correct one. Michael --- On Thu, 5/28/09, Andrew Wagner wrote: From: Andrew Wagner Subject: Re: [Haskell-cafe] Problem w/YAHT code example To: "michael rice" Cc: haskell-cafe@haskell.org Date: Thursda

Re: [Haskell-cafe] Re: Error message reform

2009-05-28 Thread wren ng thornton
Claus Reinke wrote: Still, I would really like a "just the facts, please" mode for GHC, with less text and more type signatures (especially for the contexts of type mismatches). Error messages simply not including the information I need has become my main issue with GHC messages, and seems to b

Re: [Haskell-cafe] Re: We tried this functional, higher-order stuff with LISP and look what happened...

2009-05-28 Thread Jason Dusek
2009/05/28 Benjamin L.Russell : > What makes you think that Haskell is likely eventually to "dig > a smoking hole in the ground?" This is more about unmet expectations than spectacular failure. -- Jason Dusek ___ Haskell-Cafe mailing list Haskell-Ca

Re: [Haskell-cafe] What's the problem with iota's type signature?

2009-05-28 Thread wren ng thornton
michael rice wrote: Yeah, I went back and tried double again, though I'd swear I got the dang thing to compile (and run) w/o errors. I guess I meant Num. So Num is a class and Int and Integer are types? What are the other classes? Docs? Unification, for me, is pattern matching ala Prolog. Wh

Re: [Haskell-cafe] Re: Data.Binary and little endian encoding

2009-05-28 Thread David Leimbach
On Thu, May 28, 2009 at 11:39 AM, John Van Enk wrote: > Writing instances encode/decode that use either little endian or big endian > (or mixed!) is trivial... see attached file. > > I don't see where your problem is... > Inexperience, lack of enough contiguous time to digest everything at once

Re: [Haskell-cafe] Problem w/YAHT code example

2009-05-28 Thread Andrew Wagner
I'm not sure what you're using at the end of the identifier "search'", but it needs to be the single quote that's on the same key as the double quotes. I suspect that's where it's blowing up. On Thu, May 28, 2009 at 9:56 PM, michael rice wrote: > This code, from YAHT (Section 8.4.2, PDF pg. 119

[Haskell-cafe] Problem w/YAHT code example

2009-05-28 Thread michael rice
This code, from YAHT (Section 8.4.2, PDF pg. 119 of 192) seems to have a problem. Code below. Michael = [mich...@localhost ~]$ ghci GHCi, version 6.10.1: http://www.haskell.org/ghc/  :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking .

[Haskell-cafe] Re: Who takes care of Haskell mailing lists?

2009-05-28 Thread Maurí­cio
Benjamin, I would like to create a mailing list for Portuguese speaking Haskell programmers. (...) According to "Mailing lists - HaskellWiki" (see http://haskell.org/haskellwiki/Mailing_lists), Thanks for your comprehensive reports. However, I did took all measures you sugested. "Any prob

[Haskell-cafe] Re: Error message reform (was: Strange type error with associated type synonyms)

2009-05-28 Thread Simon Michael
Achim Schneider wrote: expected/encountered Expected/actual ? Familiar to users of test frameworks. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] ANNOUNCE: Hac φ: Haskell hackathon in Philadelphia, July 24-26

2009-05-28 Thread Brent Yorgey
Greetings, I am very pleased to officially announce Hac phi, a Haskell hackathon/get-together to be held July 24-26 at the University of Pennsylvania in Philadelphia. The hackathon will officially kick off at 2:30 Friday afternoon, and go until 5pm on Sunday (with breaks for sleep, of course). T

[Haskell-cafe] Parsec float

2009-05-28 Thread Malcolm Wallace
is there any reason why float parses only positive numbers? It is usual in parsing libraries to separate the recognition of a leading sign from recognition of the number itself: the sign-only parser can be reused in many contexts, e.g. in the Haskell'98 Numeric library, there is readSi

[Haskell-cafe] Parsec float

2009-05-28 Thread Bartosz Wójcik
Hi Everybody (especially Parsec Creator), is there any reason why float parses only positive numbers? I find following defition: float = lexeme floating"float" floating= do{ n <- decimal ; fractExponent n } If floating was d

[Haskell-cafe] attaching a ghci session to another process

2009-05-28 Thread Kevin Smith
I am starting to get more involved with haskell programming and I'd like to create a program where I can use the interactive loop in ghci to run a haskell functions that create graphics in a separate openGL window. This would be a separate interactive window from the terminal i am running ghci in

Re: [Haskell-cafe] Stack overflow

2009-05-28 Thread Krzysztof Skrzętnicki
On Thu, May 28, 2009 at 14:41, Bertram Felgenhauer wrote: > Krzysztof Skrzętnicki wrote: >> 2009/5/27 Bertram Felgenhauer : >> > I wrote: >> >> Krzysztof Skrzętnicki wrote: >> >>> The code for modifying the counter: >> >>> (\ msg -> atomicModifyIORef ioref (\ cnt -> (cntMsg cnt msg,( >> >> >>

Re: [Haskell-cafe] Re: Data.Binary and little endian encoding

2009-05-28 Thread John Van Enk
Writing instances encode/decode that use either little endian or big endian (or mixed!) is trivial... see attached file. I don't see where your problem is... On Thu, May 28, 2009 at 12:35 PM, David Leimbach wrote: > > > On Thu, May 28, 2009 at 9:17 AM, John Van Enk wrote: > >> >>> Fair enoug

Re: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-28 Thread Johan Tibell
On Thu, May 28, 2009 at 6:34 PM, Duncan Coutts wrote: > If it's not available publicly perhaps you might share it privately. Don > and I have discussed a few times writing a paper on the design and > implementation of a binary library. > I would definitely like to read such a paper. Except for Do

Re: [Haskell-cafe] About the lazy pattern

2009-05-28 Thread Ryan Ingram
The main change I would make is to rename the arguments to client/server; they overload the same names (reqs/resps) as the top level declarations above, so it's very easy to get confused while reading it. Partially, I think this is just a hard concept to understand; struggling to figure it out def

Re: [Haskell-cafe] Re: Data.Binary and little endian encoding

2009-05-28 Thread Don Stewart
leimy2k: > encode/decode do Big Endian, and 9P does little endian. > > From the man page: > > "Each message consists of a sequence of bytes. Two , four , and eight byte > fields hold unsigned integers represented in little endian order (least > significant byte first)." > > encode/decode just w

Re: [Haskell-cafe] Re: Data.Binary and little endian encoding

2009-05-28 Thread David Leimbach
On Thu, May 28, 2009 at 9:17 AM, John Van Enk wrote: > >> Fair enough. I am just new to the interface, wondering if I should >> try matching responses by pulling apart via Get, or the bit syntax >> package. >> >> > > I'm assming you have some 'data Foo = ...'? If this is the case, you're > prob

Re: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-28 Thread Duncan Coutts
On Thu, 2009-05-28 at 12:08 -0400, John Van Enk wrote: > > I'm trying to implement the protocol, so that I can implement > other things on top of that. > > I'm also trying to figure out how bad/good Haskell Binary IO > really is that it's been a

[Haskell-cafe] Re: Error message reform (was: Strange type error with associated type synonyms)

2009-05-28 Thread Achim Schneider
John Dorsey wrote: > As another native English speaker, I found "expected/inferred" very > intuitive when I was new to GHC, and to Haskell. I even think that > "expected/inferred" helped me form my intuition about Haskell's type > inference. > First off, me too, and I'm not a native speaker. OT

Re: [Haskell-cafe] Re: Data.Binary and little endian encoding

2009-05-28 Thread John Van Enk
> > > Fair enough. I am just new to the interface, wondering if I should > try matching responses by pulling apart via Get, or the bit syntax > package. > > I'm assming you have some 'data Foo = ...'? If this is the case, you're probably okay writing an instance of Binary for Foo and using encod

Re: [Haskell-cafe] Re: Introducing Instances in GHC point releases

2009-05-28 Thread Henning Thielemann
On Thu, 28 May 2009, Simon Marlow wrote: Quite. I argued the "no orphan instances in libraries" position on the libraries list last year, here's the start of the (longish) thread: http://www.haskell.org/pipermail/libraries/2008-September/010618.html I remember. What I propose additionally

[Haskell-cafe] Re: Data.Binary and little endian encoding

2009-05-28 Thread David Leimbach
On Thursday, May 28, 2009, Don Stewart wrote: > leimy2k: >> I'm also trying to figure out how bad/good Haskell Binary IO really is that >> it's been addressed a few times differently :-) > > FWIW Binary IO as implemented in Data.Binary is widely used in our > production systems at Galois. I'd be f

Re: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-28 Thread John Van Enk
> > > I'm trying to implement the protocol, so that I can implement other things > on top of that. > > I'm also trying to figure out how bad/good Haskell Binary IO really is that > it's been addressed a few times differently :-) > > FWIW, I've used Data.Binary extensively and have found it a joy t

[Haskell-cafe] Re: Introducing Instances in GHC point releases

2009-05-28 Thread Simon Marlow
On 27/05/2009 22:02, Henning Thielemann wrote: My proposal is thus: Discourage orphan instances! If you encounter that an instance is missing and it is a canonical one, it should be added to the package that defines the type or the class. If there are several choices for the implementation then

Re: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-28 Thread Don Stewart
leimy2k: > I'm also trying to figure out how bad/good Haskell Binary IO really is that > it's been addressed a few times differently :-) FWIW Binary IO as implemented in Data.Binary is widely used in our production systems at Galois. I'd be fairly confident in it. -- Don _

[Haskell-cafe] gtk2hs, TreeView and CellRenderer

2009-05-28 Thread Zefirov Sergey
As far as I can tell, there is not way to create CellRenderer that could include icons with the text (I think it is because of incompatibilities of Haskell type classes and Gtk inheritance hierarchy). Is it a good way to use CellRendererPixbuf and render to pixbufs using Cairo? I think my TreeV

[Haskell-cafe] Re: Strange type error with associated type synonyms

2009-05-28 Thread Achim Schneider
Bulat Ziganshin wrote: > Hello Achim, > > Thursday, May 28, 2009, 1:34:55 AM, you wrote: > > >> Error: type of x is Integer > >> while type of read argument should be String > >> > > The problem with this is that the compiler can't know whether or not > > the type of arguments to read should

Re: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-28 Thread David Leimbach
On Thu, May 28, 2009 at 5:42 AM, Khudyakov Alexey wrote: > On Thursday 28 of May 2009 07:52:56 David Leimbach wrote: > > Sorry took so long to get back... Thank you for the response. Been > really > > busy lately :-) > > > > There are also a lot of 9P implementations in many languages that you c

RE: [Haskell-cafe] Type class context propagation investigation

2009-05-28 Thread Paul Keir
Thanks Wren, that makes sense. Ryan Ingram wrote: > Think of classes like data declarations; an instance with no context > is a constant, and one with context is a function. Here's a simple > translation of your code into data; this is very similar to the > implementation used by GHC for typeclas

Re[2]: [Haskell-cafe] Bool as type class to serve EDSLs.

2009-05-28 Thread Bulat Ziganshin
Hello Lennart, Thursday, May 28, 2009, 11:57:09 AM, you wrote: > -- | Generalization of the 'Bool' type. Used by the generalized 'Eq' and > 'Ord'. > class Boolean bool where > (&&) :: bool -> bool -> bool -- ^Logical conjunction. > (||) :: bool -> bool -> bool -- ^Logical disjunct

Re: [Haskell-cafe] Stack overflow

2009-05-28 Thread Bertram Felgenhauer
Krzysztof Skrzętnicki wrote: > 2009/5/27 Bertram Felgenhauer : > > I wrote: > >> Krzysztof Skrzętnicki wrote: > >>> The code for modifying the counter: > >>> (\ msg -> atomicModifyIORef ioref (\ cnt -> (cntMsg cnt msg,( > >> > >> atomicModifyIORef does not force the new value of the IORef. > >>

Re: [Haskell-cafe] Bool as type class to serve EDSLs.

2009-05-28 Thread Sebastiaan Visser
Or overloading the `whitespace operator' for several kinds of application. On May 28, 2009, at 9:50 AM, Augustsson, Lennart wrote: And explicit desugaring of list syntax. -Original Message- From: Sittampalam, Ganesh [mailto:ganesh.sittampa...@credit- suisse.com] Sent: 28 May 2009 08

Re: [Haskell-cafe] Data.Binary and little endian encoding

2009-05-28 Thread Khudyakov Alexey
On Thursday 28 of May 2009 07:52:56 David Leimbach wrote: > Sorry took so long to get back... Thank you for the response. Been really > busy lately :-) > > There are also a lot of 9P implementations in many languages that you can > interoperate with: > > http://9p.cat-v.org/implementations > Thank

Re: [Haskell-cafe] About the lazy pattern

2009-05-28 Thread Max Bolingbroke
2009/5/28 Petr Pudlak : > Hi Ryan, thanks for a nice and thorough explanation. I had trouble > understanding the section of the tutorial as well. Maybe it would deserve to > rewrite to something a bit simpler? > > Anyhow, I'd like to ask: Is there a reason for which pattern matching for > single-co

Re: [Haskell-cafe] About the lazy pattern

2009-05-28 Thread Petr Pudlak
Hi Ryan, thanks for a nice and thorough explanation. I had trouble understanding the section of the tutorial as well. Maybe it would deserve to rewrite to something a bit simpler? Anyhow, I'd like to ask: Is there a reason for which pattern matching for single-constructor data types isn't lazy by

Re: [Haskell-cafe] the problem of design by negation

2009-05-28 Thread Magnus Therning
On Thu, May 28, 2009 at 5:59 AM, Conal Elliott wrote: > Thanks for bringing in this angle, David. > > My preference is for honest and humble practice and documentation of > negative design.  Instead of saying that something "won't work", "can't > work", "is impossible" etc (or rephrased via "must"

Re: [Haskell-cafe] Re: What's the problem with iota's type signature?

2009-05-28 Thread Lee Duhem
On Thu, May 28, 2009 at 5:19 PM, Gracjan Polak wrote: > You don't have to guess then, Haskell compiler can do the guessing for you. It isn't guess, Haskell compiler (like GHC) gets these types by (type) inference, as you said :-) lee > It is called type inference. __

Re: [Haskell-cafe] Bool as type class to serve EDSLs.

2009-05-28 Thread Claus Reinke
Of course once you've got ifthenelse you find yourself wanting explicit desugaring of pattern matching (could view patterns help here?), Could you be more specific about what you want there, perhaps with a small example? I recognize the other problems from my own forays into EDSLs, but I'm not s

RE: [Haskell-cafe] Type class context propagation investigation[MESSAGE NOT SCANNED]

2009-05-28 Thread Paul Keir
Thanks. GHC at one stage suggested I add (Num a) => to my Num instance (after I'd added (Eq a) => to my Eq instance) and I didn't make the connection. -Original Message- From: Ryan Ingram [mailto:ryani.s...@gmail.com] Sent: Thu 28/05/2009 01:18 To: Paul Keir Cc: haskell-cafe@haskell.org S

Re: [Haskell-cafe] Lazy Parsing

2009-05-28 Thread Malcolm Wallace
Henning Thielemann wrote: > I don't think that it is in general possible to use the same parser > for lazy and strict parsing, just because of the handling of parser > failure. Polyparse demonstrates that you can mix-and-match lazy parsers with strict parsers in the different parts of a grammar

Re: [Haskell-cafe] Re: Error message reform (was: Strange type error with associated type synonyms)

2009-05-28 Thread Claus Reinke
One user's view of error message history, perhaps helpful to reformers:-) Once upon a time, Hugs tended to have "better" error messages than GHC. They still weren't perfect, mostly when begginners where confronted with messages referring to advanced concepts - eg, Simon Thompson had a list of t

[Haskell-cafe] Re: What's the problem with iota's type signature?

2009-05-28 Thread Gracjan Polak
michael rice yahoo.com> writes: > I've been digging into this stuff for months and it's still tripping me up. For exploration use GHCi. It can tell you the type of thing you have written. It has command to tell you type of thing, the ":t". See here: Prelude> let double x = Just (x + x) Prelude>

Re: [Haskell-cafe] Bool as type class to serve EDSLs.

2009-05-28 Thread Lennart Augustsson
Here's what I usually use. As Simon points out, ambiguity is lurking as soon as you use conditional. You can avoid it a fundep, but that's not necessarily what you want either. -- | Generalization of the 'Bool' type. Used by the generalized 'Eq' and 'Ord'. class Boolean bool where (&&) ::

RE: [Haskell-cafe] Bool as type class to serve EDSLs.

2009-05-28 Thread Sittampalam, Ganesh
There are multiple possible classes that you might want under different circumstances (I think the most interesting issue is whether the class (==), (>) etc is in has a fundep from the type of the thing being compared to the type of the boolean), but if NoImplicitPrelude (or some other extension) j

[Haskell-cafe] Re: We tried this functional, higher-order stuff with LISP and look what happened...

2009-05-28 Thread Benjamin L . Russell
On Wed, 27 May 2009 11:31:07 -0700, Jason Dusek wrote: > What can we say to that? I'm well practiced in handling those > who reject types outright (Python programmers), those who > reject what is too different (C programmers), those who can > not live without objects (Java programmers), those

RE: [Haskell-cafe] Bool as type class to serve EDSLs.

2009-05-28 Thread Simon Peyton-Jones
You are absolutely right about the tantalising opportunity. I know that Lennart has thought quite a bit about this very point when designing his Paradise system. Likewise Conal for Pan. One difficulty is, I think, that it's easy to get ambiguity. Eg ifthenelse (a > b) e1 e2 The (a>b)

Re: [Haskell-cafe] About the lazy pattern

2009-05-28 Thread Ketil Malde
张旭 writes: > Hi, I am really new to haskell. I am reading "A gentle instruction > to haskell" now. And I just cannot understand the chapter below. Is > there anybody who can gives me some hints about why the pattern > matching for "client" is so early? How does the pattern matching > works here?

RE: [Haskell-cafe] Template Haskell very wordy w/r/t Decs and Types

2009-05-28 Thread Simon Peyton-Jones
You already have splicing for top level decls. Splicing for local decls is a whole different ball game because it brings new *binders* into scope. For example f = ...g... g = let $(foo) in ...f... Is the 'f' inside 'g' the same 'f' as the one bound at top level? Not necessarily, because $(fo