[Haskell-cafe] Problem on overlapping instances

2011-01-05 Thread Magicloud Magiclouds
Hi, I am using Data.Binary which defined instance Binary a = Binary [a]. Now I need to define instance Binary [String] to make something special for string list. How to make it work? I looked into the chapter of overlappinginstances, nothing works. -- 竹密岂妨流水过 山高哪阻野云飞

Re: [Haskell-cafe] Problem on overlapping instances

2011-01-05 Thread Steffen Schuldenzucker
Am 05.01.2011 09:24, schrieb Magicloud Magiclouds: Hi, I am using Data.Binary which defined instance Binary a = Binary [a]. Now I need to define instance Binary [String] to make something special for string list. How to make it work? I looked into the chapter of overlappinginstances,

Re: [Haskell-cafe] Problem on overlapping instances

2011-01-05 Thread Jasper Van der Jeugt
Hello, {-# LANGUAGE OverlappingInstances, FlexibleInstances #-} import Data.Binary instance Binary [String] where get = undefined put = undefined works fine here on GHC 6.12.3. That being said, it would be safer perhaps to add a newtype around [String] so you can

Re: [Haskell-cafe] Problem on overlapping instances

2011-01-05 Thread Luke Palmer
You can't. If you have special semantics for [String], then it is not really a [String], it is something else. So let the type system know that: newtype SomethingElse = SomethingElse [String] instance Binary SomethingElse where ... On Wed, Jan 5, 2011 at 1:24 AM, Magicloud Magiclouds

Re: [Haskell-cafe] Problem on overlapping instances

2011-01-05 Thread Stephen Tetley
You have two choices (other people have enumerated the first while I was typing): First choice: Wrap your Stringlist with a newtype: newtype StringList = StringList [String] The downside of this your code gets polluted with the newtype. Second choice: Write special putStringList and

[Haskell-cafe] Network.Curl and thread safety

2011-01-05 Thread Iustin Pop
Hi all, I'm not able to find out how one can use Network.Curl with the threaded runtime safely. I have this simple example: import Network.Curl import Control.Concurrent import Control.Concurrent.MVar getUrl :: (Monad m) = String - IO (m String) getUrl url = do (code, body) - curlGetString

[Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread Jonathan Geddes
Cafe, In every language I program in, I try to be as disciplined as possible and use Test-Driven Development. That is, every language except Haskell. There are a few great benefits that come from having a comprehensive test suite with your application: 1. Refactoring is safer/easier 2. You have

Re: [Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread Erik de Castro Lopo
Jonathan Geddes wrote: snip So, am I missing the benefits of TDD in my Haskell code? Probably. I work on a project which has 4+ lines of haskell code (a compiler written in haskell) and has a huge test suite that is a vital to continued development. I've also written relatively small

[Haskell-cafe] [ANNOUNCE] Etage 0.1.7, a general data-flow framework

2011-01-05 Thread Mitar
Hi! I am glad to announce a new version of Etage, a general data-flow framework. Now it supports also GHC 7.0 and not just GHC head and because of this also Hackage successfully generates documentation so it is easier to understand the framework. http://hackage.haskell.org/package/Etage Feel

Re: [Haskell-cafe] Problem on overlapping instances

2011-01-05 Thread Magicloud Magiclouds
Steffen Schuldenzucker: Sure. GHC would prompt that. Jasper Van der Jeugt: Not working with ghc7. But there sure are some threads about this kind of things. I do not know if this is a bug of 6.* or 7, either. Luke Palmer: Sorry, by special, I meant, for example, [a, b] will be ab by

Re: [Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread Sönke Hahn
Erik de Castro Lopo wrote: Jonathan Geddes wrote: snip So, am I missing the benefits of TDD in my Haskell code? Probably. I work on a project which has 4+ lines of haskell code (a compiler written in haskell) and has a huge test suite that is a vital to continued development.

Re: [Haskell-cafe] Odd profiling results

2011-01-05 Thread Simon Marlow
On 04/01/2011 21:20, Erik de Castro Lopo wrote: Malcolm Wallace wrote: The peaks I am guessing are largely attributable to parsing the source files. Then, once the source has been converted to an AST, the DDC compiler is presumably doing some analysis before moving on to the next file? I

Re: [Haskell-cafe] thread safety, IO arrays, and IO refs

2011-01-05 Thread Simon Marlow
On 31/12/2010 09:19, Eric Stansifer wrote: Hello, I wish to use a mutable array in multiple threads. Can IO arrays be used in any thread, or only the thread they are created in? (So if I create an IO array in one thread, pass it to another via an MVar, can I read / edit it in that other

[Haskell-cafe] Choosing a type-class instance based on the context

2011-01-05 Thread Cristiano Paris
Hi all, I was reading: http://www.haskell.org/haskellwiki/GHC/AdvancedOverlap and I became curious. Playing with the code I started to find a way to say: instance Show a = ShowPred a HTrue instead of enumerating all the instances, mirroring those of the Show class: instance ShowPred Int

Re: [Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread Jake McArthur
On 01/05/2011 03:44 AM, Jonathan Geddes wrote: When I write Haskell code, I write functions (and monadic actions) that are either a) so trivial that writing any kind of unit/property test seems silly, or are b) composed of other trivial functions using equally-trivial combinators. There are

Re: [Haskell-cafe] Misleading MVar documentation

2011-01-05 Thread Bertram Felgenhauer
Mitar wrote: Hi! On Sat, Dec 25, 2010 at 11:58 AM, Edward Z. Yang ezy...@mit.edu wrote: I think you're right. A further comment is that you don't really need stringent timing conditions (which is the only thing I think of when I hear race) to see another thread grab the mvar underneath

[Haskell-cafe] Experiences with Intel's manycore lab?

2011-01-05 Thread Michael Lesniak
Hello, does anyone have experiences (good/bad) or some good-to-know knowledge about Intel's manycore lab, which supposedly has GHC 6.13 installed[1]? Regards, Michael [1]

Re: [Haskell-cafe] UTF-8 BOM

2011-01-05 Thread Gregory Collins
Use the text library instead? On Jan 5, 2011 2:09 AM, Tony Morris tonymor...@gmail.com wrote: I am reading files with System.IO.readFile. Some of these files start with a UTF-8 Byte Order Marker (0xef 0xbb 0xbf). For some functions that process this String, this causes choking so I drop the

Re: [Haskell-cafe] Trouble installing FileManipCompat

2011-01-05 Thread Tony Miller
Thanks that works, but I have packages that rely on mtl=2.0, so its not the best solution. Perhaps the maintainer of FileManipCompat could be contacted to update the package? On 1/4/11, Daniel Fischer daniel.is.fisc...@googlemail.com wrote: On Wednesday 05 January 2011 01:54:36, Tony Miller

Re: [Haskell-cafe] Trouble installing FileManipCompat

2011-01-05 Thread Daniel Fischer
On Wednesday 05 January 2011 19:43:53, Tony Miller wrote: Thanks that works, but I have packages that rely on mtl=2.0, so its not the best solution. Perhaps the maintainer of FileManipCompat could be contacted to update the package? Visiting http://hackage.haskell.org/package/FileManip reveals

Re: [Haskell-cafe] Choosing a type-class instance based on the context

2011-01-05 Thread Stephen Tetley
Though its quite different to AdvancedOverlap, Conal Elliott has a method of answering the title of your post - Choosing a type-class instance based on the context. See the CxMonoid (context monoid) in Section 3. Flexible Layout of the paper Applicative Data-Driven Computation.

Re: [Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread Jonathan Geddes
The Haskell type system is simply not rich enough to guarantee everything you might need. That's true, and after giving this a bit more thought, I realized it's not JUST the type system that I'm talking about here. There are a few other features that make it hard for me to want to use

Re: [Haskell-cafe] Experiences with Intel's manycore lab?

2011-01-05 Thread Johannes Waldmann
[1] http://software.intel.com/en-us/blogs/2010/10/14/prerelease-ghc-and-haskell-cnc-installed-on-intels-manycore-testing-lab-for-academic-use-2/ Very interesting. Had this been advertised here before? Besides the technical issues - what kind of personal data does Intel collect? I understand

Re: [Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread Anthony Cowley
On Wed, Jan 5, 2011 at 3:02 PM, Jonathan Geddes geddes.jonat...@gmail.com wrote: The Haskell type system is simply not rich enough to guarantee everything you might need. Despite all this, I suspect that since Haskell is at a higher level of abstraction than other languages, the tests in

Re: [Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread Edward Z. Yang
Haskell's type system makes large classes of traditional unit tests irrelevant. Here are some examples: - Tests that simply run code to make sure there are no syntax errors or typos, - Tests that exercise simple input validation that is handled by the type system, i.e.

Re: [Haskell-cafe] Building lambdabot

2011-01-05 Thread Rogan Creswick
On Tue, Jan 4, 2011 at 5:16 PM, Joe Bruce bruce.jo...@gmail.com wrote: I've had a bit of an adventure trying to build and run lambdabot on my box.  'cabal install lambdabot' does not work.  It states it's not GHC 6.12 (and certainly not 7.0) compatible, but I tried 6.12 anyway and got nowhere.

Re: [Haskell-cafe] Building lambdabot

2011-01-05 Thread Rogan Creswick
On Wed, Jan 5, 2011 at 12:53 PM, Rogan Creswick cresw...@gmail.com wrote: State.  I didn't have any trouble building lambdabot after setting an upper version bound on the mtl dependency in lambdabot.cabal:  Library    build-depends: base, mtl = 2.0, bytestring, unix My mistake, that should

Re: [Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread Gregory Collins
On Wed, Jan 5, 2011 at 9:02 PM, Jonathan Geddes geddes.jonat...@gmail.com wrote: Despite all this, I suspect that since Haskell is at a higher level of abstraction than other languages, the tests in Haskell must be at a correspondingly higher level than the tests in other languages. I can see

Re: [Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread Iustin Pop
On Wed, Jan 05, 2011 at 10:27:29PM +0100, Gregory Collins wrote: Once I had written the test harness, I spent literally less than a half-hour setting this up. Highly recommended, even if it is a (blech) Java program. Testing is one of the few areas where I think our software engineering

Re: [Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread Erik de Castro Lopo
Jonathan Geddes wrote: I know that much of my code could benefit from a property test or two on the more complex parts, but other than that I can't think that unit testing will improve my Haskell code/programming practice. One other thing I should mention that is that since a lot of Haskell

Re: [Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread John Zabroski
These are some heuristics memories I have for myself, and you can feel free to take whatever usefulness you can get out of it. 1. Don't confuse TDD with writing tests, in general. 2. Studies show that if you do TDD, you can write more tests than if you write tests after you write the code.

Re: [Haskell-cafe] Choosing a type-class instance based on the context

2011-01-05 Thread Cristiano Paris
On Wed, Jan 5, 2011 at 20:35, Stephen Tetley stephen.tet...@gmail.com wrote: Though its quite different to AdvancedOverlap, Conal Elliott has a method of answering the title of your post - Choosing a type-class instance based on the context. See the CxMonoid (context monoid) in Section 3.

Re: [Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread John Zabroski
On Wed, Jan 5, 2011 at 6:41 PM, John Zabroski johnzabro...@gmail.comwrote: 5. I have a hard time understanding statements like The difficulties in unit testing OO code is coaxing objects into the correct state to test a particular property. Difficulty in unit testing OO code is best

[Haskell-cafe] What's the best seed for random API ?

2011-01-05 Thread z_axis
picoSec :: IO Integer picoSec = do t - ctPicosec `liftM` (getClockTime = toCalendarTime) return t rollDice :: Int - IO Int rollDice n = do ps - picoSec return $ (take 1 $ randomRs (1,n) $ mkStdGen $ fromInteger ps) !! 0 The above code uses `ctPicosec` as seed. Is it better to

Re: [Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread Erik de Castro Lopo
John Zabroski wrote: 5. I have a hard time understanding statements like The difficulties in unit testing OO code is coaxing objects into the correct state to test a particular property. This is my direct experience of inheriting code written by others without any tests and trying to add

Re: [Haskell-cafe] What's the best seed for random API ?

2011-01-05 Thread Alex Rozenshteyn
Admittedly, I don't know much about this from the haskell end or about the particular api. If you want statistical randomness, your seed doesn't matter; just the PRNG. I might even have seeded with a constant or taken the seed from the user. Seeding from urandom will make your output more

Re: [Haskell-cafe] What's the best seed for random API ?

2011-01-05 Thread Robert Clausecker
It probably is, but definitly not portable. Try to find /dev/urandom under Windows. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread Evan Laforge
On Wed, Jan 5, 2011 at 1:27 PM, Gregory Collins g...@gregorycollins.net wrote: On Wed, Jan 5, 2011 at 9:02 PM, Jonathan Geddes geddes.jonat...@gmail.com wrote: Despite all this, I suspect that since Haskell is at a higher level of abstraction than other languages, the tests in Haskell must be

Re: [Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread Chung-chieh Shan
Evan Laforge qdun...@gmail.com wrote in article aanlktinfyp-bpbs1ga8_=o9wcrhe+duux-vfrmdl2...@mail.gmail.com in gmane.comp.lang.haskell.cafe: Incidentally, I've never been able to figure out how to use QuickCheck. Maybe it has more to do with my particular app, but QuickCheck seems to expect

Re: [Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread Jesse Schalken
You need both. A good static type system will tell you whether or not the code is type-correct. It will not tell you whether or not it does what it's supposed to do. Consider: sort :: [a] - [a] If you change sort to be: sort = id It will still type check, but it obviously doesn't do what

Re: [Haskell-cafe] UTF-8 BOM

2011-01-05 Thread Mark Lentczner
On Jan 4, 2011, at 5:41 PM, Antoine Latter wrote: Are you thinking that the BOM should be automatically stripped from UTF8 text at some low level, if present? It should not. Wether or not a U+FFEF can be stripped depends on context in which it is found. There is no way that lower level code,

Re: [Haskell-cafe] Odd profiling results

2011-01-05 Thread Erik de Castro Lopo
Simon Marlow wrote: Or the C compiler, perhaps? Thanks for the suggesion Simon. This one was actually easier to test that Malcolm's suggestion. To test it, I ran the same test under Oprofile [0], the Linux kernel based profiler. OProfile is really cool because it profiles the whole system,

Re: [Haskell-cafe] Building lambdabot

2011-01-05 Thread Joe Bruce
Rogan, Thanks for taking a look at it. No, mtl is not the problem, at least not yet. A detail that I've discovered is important: I'm on Mac OS X (10.6). readline is my problem, and readline + mac + haskell seems to be a bad mix. Macports installs readline in /opt/local/ by default, so I

Re: [Haskell-cafe] Type System vs Test Driven Development

2011-01-05 Thread Arnaud Bailly
I would supplement this excellent list of advices with an emphasis on the first one: Test-Driven Development is *not* testing, TDD is a *design* process. Like you said, it is a discipline of thought that forces you first to express your intent with a test, second to write the simplest thing that