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

2009-05-29 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] Ensuring Type Class instances follow the 'rules'

2009-05-29 Thread Eugene Kirpichov
Use QuickCheck. 2009/5/29 Hemanth Kapila saihema...@gmail.com: 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

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

2009-05-29 Thread Thomas ten Cate
What comes to my mind is that you could launch your program from inside GHCi, instead of the other way round. Just write an IO () function that spawns a new thread for the window, graphics, input handling and all that. Call this function from GHCi and your window will appear. Then write some other

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

2009-05-29 Thread wren ng thornton
Eugene Kirpichov wrote: Use QuickCheck. Also use SmallCheck or lazy SmallCheck. All of these are automatic tools that allow you to specify laws[1] and automatically generate values for testing the law. QuickCheck generates values randomly, which can be useful but is very often insufficient.

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

2009-05-29 Thread Nicolas Pouillard
Excerpts from Bulat Ziganshin's message of Thu May 28 15:07:02 +0200 2009: 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 --

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

2009-05-29 Thread Ketil Malde
Duncan Coutts duncan.cou...@worc.ox.ac.uk writes: FWIW, I've used Data.Binary extensively and have found it a joy to work with. I've used it to serialize/deserialize ethernet packets in real time for a VPN implementation and have never had a problem. It's quite fast and robust. Is that code

[Haskell-cafe] Re: I love purity, but it's killing me.

2009-05-29 Thread Heinrich Apfelmus
Conal Elliott wrote: Sittampalam, Ganesh wrote In my experience [1], observable sharing using GHC's stable names is a pretty effective solution to this problem. Plus unsafePerformIO and weak references as in *Stretching the storage manager: weak pointers and stable names in

[Haskell-cafe] ghc - force library search order

2009-05-29 Thread John Lask
I need to force a library to be searched for unresolved symbols after all other libraries have been searched, and I would rather not resort to constructing the linker command line directly. Is there a way to do this? i.e. I want for example -lfoo to appear after all other haskell libraries

Re: [Haskell-cafe] Lazy Parsing

2009-05-29 Thread S. Doaitse Swierstra
Lazy parsing has been the default for the last ten years in uulib, and is now available in the simple uu-parsinglib (http://hackage.haskell.org/cgi-bin/hackage-scripts/package/uu-parsinglib ). The whole design of the latter in described in a technical report to which references are given on

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

2009-05-29 Thread Johan Tibell
On Fri, May 29, 2009 at 2:17 AM, Simon Michael si...@joyful.com wrote: Achim Schneider wrote: expected/encountered Expected/actual ? Familiar to users of test frameworks. That does sound better than expected/inferred to me. -- Johan ___

Re: [Haskell-cafe] Lazy Parsing

2009-05-29 Thread S. Doaitse Swierstra
In the uu-parsinglib we actually have two versions of parsers: lazy ones and strict ones, which have different types. So by giving a type annotation you can select the one you want. Notice that in the left- hand side of a monadic construct it does not make sense to use a lazy parser, since

Re: [Haskell-cafe] Parsec float

2009-05-29 Thread Tillmann Vogt
Bartosz Wójcik wrote: 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

[Haskell-cafe] [] == []

2009-05-29 Thread Paul Keir
Hi all, GHC is not happy with this: f = [] == [] nor this: f' = ([]::(Eq a) = [a]) == ([]::(Eq a) = [a]) but this is OK: f'' = ([]::[Integer]) == ([]::[Integer]) GHCI is comfortable with [] == [], so why not GHC? 'Just curious. Cheers, Paul ___

Re: [Haskell-cafe] [] == []

2009-05-29 Thread Eugene Kirpichov
2009/5/29 Paul Keir pk...@dcs.gla.ac.uk: Hi all, GHC is not happy with this: f = [] == [] This fails because GHC doesn't know which 'a' you mean, and can't choose an Eq instance. nor this: f' = ([]::(Eq a) = [a]) == ([]::(Eq a) = [a]) This fails for the same reason. but this is OK:

Re: [Haskell-cafe] [] == []

2009-05-29 Thread Roman Cheplyaka
* Paul Keir pk...@dcs.gla.ac.uk [2009-05-29 10:47:26+0100] Hi all, GHC is not happy with this: f = [] == [] nor this: f' = ([]::(Eq a) = [a]) == ([]::(Eq a) = [a]) Here, there's no guarantee that the answer will be the same independent of what 'a' you choose. Potentially, you could

RE: [Haskell-cafe] [] == []

2009-05-29 Thread Paul Keir
f''' = ([]::[()]) == ([]::[()]) (Very pretty.) So why doesn't ghc have 'default' instances? -Original Message- From: Eugene Kirpichov [mailto:ekirpic...@gmail.com] Sent: Fri 29/05/2009 10:51 To: Paul Keir Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] [] == [][MESSAGE NOT

Re: [Haskell-cafe] [] == []

2009-05-29 Thread Max Rabkin
On Fri, May 29, 2009 at 12:29 PM, Paul Keir pk...@dcs.gla.ac.uk wrote: f''' = ([]::[()]) == ([]::[()]) (Very pretty.) So why doesn't ghc have 'default' instances? It does. I believe Num defaults to Integer and then to Double. Generally, though, defaults are convenient in exploratory usage

Re: [Haskell-cafe] Lazy Parsing

2009-05-29 Thread Guenther Schmidt
Dear Doaitse, In the days since my original post I had already come to favor the uu-parsing package. I have printed the report and read it every day to figure out how to use it. I cannot follow everything yet, and also hope that won't be necessary in order to use it. :-) My progress is a bit

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

2009-05-29 Thread Hemanth Kapila
Thanks Eugene and wren. Serves me right, actually. The one chapter I skipped in RWH was the 11th one called Testing and Quality Assurance thinking it is too boring. On Fri, May 29, 2009 at 12:44 PM, wren ng thornton w...@freegeek.orgwrote: Eugene Kirpichov wrote: Use QuickCheck. Also use

[Haskell-cafe] Floating instance and pi

2009-05-29 Thread Paul Keir
Hi, I'd like to make my ADT an instance of the Floating class, but I'm not sure what to put for pi, and GHC gives a warning without it: Warning: No explicit method nor default method for `GHC.Float.pi' I tried setting it to undefined, but that gives an error: `pi' is not a (visible) method of

[Haskell-cafe] How to interprete profile output

2009-05-29 Thread Sebastian Reese
Hi there, i am currently working on the mapreduce framework (http://darcs2.fh-wedel.de/repos/holumbus/) which can also be found in hackage. I was doing the simple WordFrequency example, which does nothing but counting word frequencies and runs a few seconds. When I run this program

[Haskell-cafe] Haskell and symbolic references

2009-05-29 Thread Patrick LeBoutillier
Hi all, Is it possible with Haskell to call a function whose name is contained in a String? Something like: five = call_func add [2, 3] If not, perhaps this is acheivable using FFI? Thanks a lot, Patrick Leboutillier -- = Patrick LeBoutillier Rosemère, Québec, Canada

RE: [Haskell-cafe] Haskell and symbolic references

2009-05-29 Thread Bayley, Alistair
From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Is it possible with Haskell to call a function whose name is contained in a String? Something like: five = call_func add [2, 3] If not, perhaps this is acheivable using FFI? Dynamic loading

Re: [Haskell-cafe] Floating instance and pi

2009-05-29 Thread Deniz Dogan
2009/5/29 Paul Keir pk...@dcs.gla.ac.uk: Hi, I'd like to make my ADT an instance of the Floating class, but I'm not sure what to put for pi, and GHC gives a warning without it: Warning: No explicit method nor default method for `GHC.Float.pi' I tried setting it to undefined, but that

[Haskell-cafe] IFL 2009: Second Call for Papers

2009-05-29 Thread IFL 2009
Call for Papers IFL 2009 Seton Hall University SOUTH ORANGE, NJ, USA http://tltc.shu.edu/blogs/projects/IFL2009/ ** NEW ** Accomodations information available: http://tltc.shu.edu/blogs/projects/IFL2009/accommodations.html Jane Street Capital has joined IFL 2009 as a sponsor * The

Re: [Haskell-cafe] Haskell and symbolic references

2009-05-29 Thread Jake McArthur
Patrick LeBoutillier wrote: Hi all, Is it possible with Haskell to call a function whose name is contained in a String? Something like: five = call_func add [2, 3] You could use Data.Map: call_func = (funcMap !) where funcMap = fromList [ (add, add)

RE: [Haskell-cafe] Floating instance and pi

2009-05-29 Thread Paul Keir
Oops, I was hiding the Prelude's pi. My apologies. -Original Message- From: Deniz Dogan [mailto:deniz.a.m.do...@gmail.com] Sent: Fri 5/29/2009 5:01 PM To: Paul Keir Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Floating instance and pi[MESSAGE NOT SCANNED] 2009/5/29 Paul Keir

Re: [Haskell-cafe] Haskell and symbolic references

2009-05-29 Thread Khudyakov Alexey
On Friday 29 of May 2009 19:34:44 Patrick LeBoutillier wrote: Hi all, Is it possible with Haskell to call a function whose name is contained in a String? Something like: five = call_func add [2, 3] If not, perhaps this is acheivable using FFI? Or maybe you are asking for template

[Haskell-cafe] Hugs vs. GHCi

2009-05-29 Thread Vladimir Reshetnikov
Hi, The following expression evaluates to 1 in GHCi, but results in an error in Hugs: let f x = let g y = [x,y] in (g 1, g []) in 1 What is the correct behavior? Thanks Vladimir ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

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

2009-05-29 Thread Ryan Ingram
Just pretend it was named Test Driven Development so it feels more sexy while you read it :) -- ryan On Fri, May 29, 2009 at 5:05 AM, Hemanth Kapila saihema...@gmail.com wrote: Thanks Eugene and wren. Serves me right, actually. The one chapter I skipped in RWH was the 11th one called

Re: [Haskell-cafe] Hugs vs. GHCi

2009-05-29 Thread Dan Weston
http://haskell.org/onlinereport/exps.html#sect3.12 Pattern bindings are matched lazily; an implicit ~ makes these patterns irrefutable. For example, let (x,y) = undefined in e does not cause an execution-time error until x or y is evaluated. So GHCi is correct. Dan Vladimir Reshetnikov

Re: [Haskell-cafe] Hugs vs. GHCi

2009-05-29 Thread Daniel Fischer
Am Freitag 29 Mai 2009 20:35:47 schrieb Dan Weston: http://haskell.org/onlinereport/exps.html#sect3.12 Pattern bindings are matched lazily; an implicit ~ makes these patterns irrefutable. For example, let (x,y) = undefined in e does not cause an execution-time error until x or y is

Re: [Haskell-cafe] Parsec float

2009-05-29 Thread Bartosz Wójcik
On Friday 29 May 2009 08:34:36 you wrote: myfloat = try (do{ symbol -; n - float; return (negate n) }) |            try float |                do { i-integer; return(fromIntegral i) } Thank you, this is an easy and nice solution. I've made it a bit prettier optically: myFloat = try (symbol -

Re: [Haskell-cafe] Parsec float

2009-05-29 Thread Bryan O'Sullivan
On Fri, May 29, 2009 at 3:38 PM, Bartosz Wójcik bar...@sudety.it wrote: Thank you, this is an easy and nice solution. I've made it a bit prettier optically: myFloat = try (symbol - float = return . negate) | try float | (integer = return . fromIntegral) Any time you see =

Re: [Haskell-cafe] Parsec float

2009-05-29 Thread Bartosz Wójcik
On Friday 29 May 2009 22:10:51 Bryan O'Sullivan wrote: myFloat = try (symbol - float = return . negate) | try float | (integer = return . fromIntegral) Any time you see = return ., something is being missed. Use liftM or $ instead, i.e. fromIntegral $ integer instead of integer

Re: [Haskell-cafe] Parsec float

2009-05-29 Thread Daniel Fischer
Am Samstag 30 Mai 2009 02:04:29 schrieb Bartosz Wójcik: On Friday 29 May 2009 22:10:51 Bryan O'Sullivan wrote: myFloat = try (symbol - float = return . negate) | try float | (integer = return . fromIntegral) Any time you see = return ., something is being missed. Use liftM

Re: [Haskell-cafe] Parsec float

2009-05-29 Thread David Menendez
On Fri, May 29, 2009 at 8:04 PM, Bartosz Wójcik bar...@sudety.it wrote: On Friday 29 May 2009 22:10:51 Bryan O'Sullivan wrote: myFloat = try (symbol - float = return . negate)     |  try float     |  (integer = return . fromIntegral) Any time you see = return ., something is being

Re: [Haskell-cafe] Parsec float

2009-05-29 Thread Derek Elkins
On Fri, May 29, 2009 at 4:02 AM, Tillmann Vogt tillmann.v...@rwth-aachen.de wrote: Bartosz Wójcik wrote: Hi Everybody (especially Parsec Creator), is there any reason why float parses only positive numbers? I find following defition: float           = lexeme floating   ? float floating  

Re: [Haskell-cafe] Parsec float

2009-05-29 Thread Bryan O'Sullivan
On Fri, May 29, 2009 at 5:04 PM, Bartosz Wójcik bar...@sudety.it wrote: I don't undersdand what is being missed. Brevity. liftM f m1 = do { x1 - m1; return (f x1) } so liftM fromIntegral integer will result the same. Yes, and there's less code to read if you use liftM or

[Haskell-cafe] can someone point me to more help about Database.HDBC.ODBC?

2009-05-29 Thread Michael P Mossey
I'm trying to use Database.HDBC.ODBC to connect to a MySQL server, and I cannot figure out the docs. I want to establish a connection, and I know the server url, username, and password. According to these docs...

Re: [Haskell-cafe] can someone point me to more help about Database.HDBC.ODBC?

2009-05-29 Thread Justin Bailey
Try this: http://www.connectionstrings.com/ On Fri, May 29, 2009 at 8:01 PM, Michael P Mossey m...@alumni.caltech.edu wrote: I'm trying to use Database.HDBC.ODBC to connect to a MySQL server, and I cannot figure out the docs. I want to establish a connection, and I know the server url,

Re: [Haskell-cafe] can someone point me to more help about Database.HDBC.ODBC?

2009-05-29 Thread Евгений Тарасов
Usually you should pass only DSN name in the string, if you used InnoDB database in MySQL. For example, /etc/odbc.ini file: ; ; odbc.ini configuration for MyODBC and MyODBC 3.51 Drivers ; [.] [Default] Driver = MySQL Description = MySQL ODBC 3.51 Driver DSN Server = localhost