Re: [Haskell-cafe] Design question

2009-12-16 Thread Luke Palmer
On Wed, Dec 16, 2009 at 9:40 AM, hask...@kudling.de hask...@kudling.de wrote: Hi, i am not quite sure how to do this in the most elegant way: I have some data structures: data A = A Double data B = B Double data C = C Double ... and i want to allow only a subset in another data

Re: [Haskell-cafe] SmallCheck design question

2009-12-11 Thread Johannes Waldmann
2. why depth and not size (= total number of constructors)? That seems harder to generate terms compositionally. To create all terms of depth n+1 you just glue together all terms of depth n, but to create terms of size n+1 you need to glue 1 with n, 2 with n-1 etc. So? One would fear that

Re: [Haskell-cafe] SmallCheck design question

2009-12-08 Thread Neil Mitchell
Hi, I'm cc'ing the people behind smallcheck, who can give definitive answers. 1. why are the tuple constructors treated differently? I'd expect depth (x,y) = succ $ max (depth x) (depth y) but the succ is missing. I think this was a design choice. Some people would consider: data Foo = Foo

Re: [Haskell-cafe] Hayoo and Hoogle (beginner question)

2009-12-07 Thread Ketil Malde
Lyndon Maydwell maydw...@gmail.com writes: On Mon, Dec 7, 2009 at 2:43 PM, Colin Adams colinpaulad...@googlemail.com wrote: 2009/12/7 drostin77 ml.nwgr...@gmail.com: Hello Hopefully Helpful Haskell Community! (I really wanted that to be alliteration... couldn't come up with an h word

Re: [Haskell-cafe] Hayoo and Hoogle (beginner question)

2009-12-07 Thread drostin77
___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- View this message in context: http://old.nabble.com/Hayoo-and-Hoogle-%28beginner-question%29-tp26669924p26674323.html Sent from the Haskell - Haskell-Cafe

Re: [Haskell-cafe] Hayoo and Hoogle (beginner question)

2009-12-07 Thread Lyndon Maydwell
in the footprints of giants ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- View this message in context: http://old.nabble.com/Hayoo-and-Hoogle-%28beginner-question%29-tp26669924p26674323

Re: [Haskell-cafe] Hayoo and Hoogle (beginner question)

2009-12-07 Thread Roel van Dijk
On Mon, Dec 7, 2009 at 10:24 AM, Lyndon Maydwell maydw...@gmail.com wrote: I had heard that Hoogle actually compiled any type-signatures, where as Hayoo just did a text comparison. I'm not actually sure if this is true or not though. If it is, it would mean that [q] - [r] - [(q,r)] would

Re: [Haskell-cafe] Hayoo and Hoogle (beginner question)

2009-12-07 Thread Timo B. Hübel
in Hoogle, but not Hayoo. Am I right about this? Yes, we (in Hayoo!) only do text based stuff. Is is possbile to search for signatures, but no generalization etc. is done at all. This is very primitive in Hayoo! and I really suggest using Hoogle for type searches. As for the question about

Re: [Haskell-cafe] Hayoo and Hoogle (beginner question)

2009-12-07 Thread Neil Mitchell
place, or if they are already answered in detail somewhere that my Googling didn't find please feel free to paste a link and tell me to search better next time! -- View this message in context: http://old.nabble.com/Hayoo-and-Hoogle-%28beginner-question%29-tp26669924p26669924.html Sent from

Re: [Haskell-cafe] Hayoo and Hoogle (beginner question)

2009-12-07 Thread Ivan Lazar Miljenovic
Neil Mitchell ndmitch...@gmail.com writes: but if you use Hayoo for some reason other than Hoogle not searching all packages, I'd love to know. Isn't it obvious? We all use Hayoo for the Web 2.0 interface! :p /me is just kidding -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com

[Haskell-cafe] SmallCheck design question

2009-12-07 Thread Johannes Waldmann
referring to the Serial instances in http://hackage.haskell.org/package/smallcheck : the idea is that series d gives all objects of depth = d. depth of a term from an algebraic data type is the standard depth concept for trees (maximum nesting of constructors = longest path from root to node)

Re: [Haskell-cafe] Hayoo and Hoogle (beginner question)

2009-12-07 Thread drostin77
.  If these questions are in the wrong place, or if they are already answered in detail somewhere that my Googling didn't find please feel free to paste a link and tell me to search better next time! -- View this message in context: http://old.nabble.com/Hayoo-and-Hoogle-%28beginner-question%29

[Haskell-cafe] Hayoo and Hoogle (beginner question)

2009-12-06 Thread drostin77
me to search better next time! -- View this message in context: http://old.nabble.com/Hayoo-and-Hoogle-%28beginner-question%29-tp26669924p26669924.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing

Re: [Haskell-cafe] Hayoo and Hoogle (beginner question)

2009-12-06 Thread Colin Adams
2009/12/7 drostin77 ml.nwgr...@gmail.com: Hello Hopefully Helpful Haskell Community! (I really wanted that to be alliteration... couldn't come up with an h word for community) House? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Hayoo and Hoogle (beginner question)

2009-12-06 Thread Lyndon Maydwell
'Hood? On Mon, Dec 7, 2009 at 2:43 PM, Colin Adams colinpaulad...@googlemail.com wrote: 2009/12/7 drostin77 ml.nwgr...@gmail.com: Hello Hopefully Helpful Haskell Community! (I really wanted that to be alliteration... couldn't come up with an h word for community) House?

[Haskell-cafe] module export question

2009-12-01 Thread Sean McLaughlin
Say I have the following module: module A ( T(T) , t , val ) where data T = T { t :: Int } val :: T val = T 7 When I use A with the following imports, I don't expect this to work, but it does: import

Re: [Haskell-cafe] module export question

2009-12-01 Thread Luke Palmer
On Tue, Dec 1, 2009 at 3:11 PM, Sean McLaughlin sean...@gmail.com wrote: Say I have the following module: module A  ( T(T)  , t  , val  ) where data T = T { t :: Int } val :: T val = T 7 When I use

Re: [Haskell-cafe] module export question

2009-12-01 Thread Ross Mellgren
It looks like it is specified and the intended behavior: From the report, section 5.2: An algebraic datatype T declared by a data or newtype declaration may be named in one of three ways: The form T names the type but not the constructors or field names. The ability to export a type without

Re: [Haskell-cafe] module export question

2009-12-01 Thread Ross Paterson
On Tue, Dec 01, 2009 at 05:11:42PM -0500, Sean McLaughlin wrote: The problem is that I explicitly didn't export 't' as an element of T (by not writing T(..)). Am I just misunderstanding how exports work? I couldn't figure out what the correct behavior should be by looking at the 98 report.

[Haskell-cafe] License question

2009-11-30 Thread jean-christophe mincke
Hello, I am writing a port to F# of some haskell standard libraries. I would like to publish them under an open source license and mention the origin of the initial code. www.haskell.org is under the simple permissive license. Does this license also cover the souce code available from that

Re: [Haskell-cafe] License question

2009-11-30 Thread Bulat Ziganshin
Hello jean-christophe, Monday, November 30, 2009, 11:43:00 AM, you wrote: I am writing a port to F# of some haskell standard libraries. www.haskell.org is under the simple permissive license.  Does this license also cover the souce code available from that site? the license cover only Wiki

Re: [Haskell-cafe] License question

2009-11-30 Thread Malcolm Wallace
www.haskell.org is under the simple permissive license. Does this license also cover the souce code available from that site? the license cover only Wiki contents. std haskell libraries covered by BSD3 license, for example as a part of bsd3-covered GHC distribution And in fact the

Re: [Haskell-cafe] License question

2009-11-30 Thread Duncan Coutts
On Mon, 2009-11-30 at 09:43 +0100, jean-christophe mincke wrote: Hello, I am writing a port to F# of some haskell standard libraries. I would like to publish them under an open source license and mention the origin of the initial code. www.haskell.org is under the simple permissive

Re[2]: [Haskell-cafe] License question

2009-11-30 Thread Bulat Ziganshin
Hello Malcolm, Monday, November 30, 2009, 1:45:29 PM, you wrote: And in fact the official Haskell'98 libraries are covered by an even more permissive license: that of the Language Report. The authors intend this Report to belong to the entire Haskell community, and so we grant permission

Re: Re[2]: [Haskell-cafe] License question

2009-11-30 Thread Malcolm Wallace
i don't think that reproducing in its entirety is more permissive for his purpose :) I think translating to F# counts as modification, so the other clause of the license applies; namely you can do anything you like with it, provided you do not claim it defines Haskell'98. Regards,

[Haskell-cafe] Re: Iteratee question

2009-11-26 Thread oleg
Valery V. Vorotyntsev wrote: The following pattern appears quite often in my code: results - map someConversion `liftM` replicateM nbytes Iter.head The meaning is: take `nbytes' from stream, apply `someConversion' to every byte and return the list of `results'. But there's more than one

[Haskell-cafe] Re: Iteratee question

2009-11-26 Thread Valery V. Vorotyntsev
On Thu, Nov 26, 2009 at 10:17 AM, o...@okmij.org wrote: You are correct: i2 and i3 can process a chunk of elements at a time, if an enumerator supplies it. That means an iteratee like i2 or i3 can do more work per invocation -- which is always good. Since you have to get the results as a

[Haskell-cafe] Re: Iteratee question

2009-11-26 Thread Valery V. Vorotyntsev
On Fri, Nov 27, 2009 at 4:04 AM, John Lato jwl...@gmail.com wrote: My apologies for not replying; I have been traveling and am only now working through my email. Oleg's response is much better than anything I would have written. I'd like to add one point. stream2list is very inefficient as

[Haskell-cafe] Existential type question

2009-11-22 Thread Michael Snoyman
Hi all, I've come across some code I just can't figure out how to write appropriately. Below is a silly example that demonstrates what I'm trying to do. I don't really have the appropriate vocabulary to describe the issue, so I'll let the code speak for itself. In particular, I'm trying to

Re: [Haskell-cafe] Existential type question

2009-11-22 Thread Daniel Fischer
Am Sonntag 22 November 2009 19:24:48 schrieb Michael Snoyman: Hi all, I've come across some code I just can't figure out how to write appropriately. Below is a silly example that demonstrates what I'm trying to do. I don't really have the appropriate vocabulary to describe the issue, so I'll

[Haskell-cafe] Iteratee question

2009-11-20 Thread Valery V. Vorotyntsev
I am writing a binary data parser and use `iteratee' package. The following pattern appears quite often in my code: results - map someConversion `liftM` replicateM nbytes Iter.head The meaning is: take `nbytes' from stream, apply `someConversion' to every byte and return the list of `results'.

[Haskell-cafe] (possibly) a list comprehensions question

2009-11-19 Thread Ozgur Akgun
],[3,4,5],[6,7]] -- [[1,3,6],[1,3,7],[1,4,6],[1,4,7],[1,5,6],[1,5,7],[2,3,6],[2,3,7],[2,4,6],[2,4,7],[2,5,6],[2,5,7]] This is ugly! Anyway, just forget the fact that these funstions do not do a check on the length of the input list for a moment. My question is, how can I generalize this function

Re: [Haskell-cafe] (possibly) a list comprehensions question

2009-11-19 Thread Eugene Kirpichov
on the length of the input list for a moment. My question is, how can I generalize this function to accept a list of lists of arbitrary length, and produce the required result. I hope I managed to make my point clear enough. Waiting for suggestions. Regards, -- Ozgur Akgun

Re: [Haskell-cafe] (possibly) a list comprehensions question

2009-11-19 Thread Neil Brown
Ozgur Akgun wrote: Anyway, just forget the fact that these funstions do not do a check on the length of the input list for a moment. My question is, how can I generalize this function to accept a list of lists of arbitrary length, and produce the required result. Hi, The concise solution

Re: [Haskell-cafe] (possibly) a list comprehensions question

2009-11-19 Thread Ozgur Akgun
, I'll definitely have a look at the implementation of sequence. Cheers! 2009/11/19 Neil Brown nc...@kent.ac.uk Ozgur Akgun wrote: Anyway, just forget the fact that these funstions do not do a check on the length of the input list for a moment. My question is, how can I generalize

[Haskell-cafe] Re: (possibly) a list comprehensions question

2009-11-19 Thread yair...@gmail.com
Ozgur Akgun wrote: Anyway, just forget the fact that these funstions do not do a check on the length of the input list for a moment. My question is, how can I generalize this function to accept a list of lists of arbitrary length, and produce the required result. Hi, The concise

Re: [Haskell-cafe] Re: (possibly) a list comprehensions question

2009-11-19 Thread Ozgur Akgun
question is, how can I generalize this function to accept a list of lists of arbitrary length, and produce the required result. Hi, The concise solution is the list monad, as already posted. If that confuses you, here is a version using list comprehensions (well, mostly

Re: [Haskell-cafe] haskell-src-exts Question

2009-11-16 Thread Sebastian Fischer
Hello, On Nov 13, 2009, at 11:54 PM, Niklas Broberg wrote: But the problem at hand here is auto-generated AST code, where we cannot rely on the parser to do the right thing. There's help in the AST such that it's possible to explicitly insert brackets where needed, but I agree with Dominic

[Haskell-cafe] Re: haskell-src-exts Question

2009-11-16 Thread Dominic Steinitz
Niklas Broberg niklas.broberg at gmail.com writes: please? http://trac.haskell.org/haskell-src-exts Niklas, I'd love to raise a bug for it but unfortunately I can't log on to trac. I don't understand why but none of my colleagues can log on either. It's been a long standing issue. I presume

[Haskell-cafe] Re: haskell-src-exts Question

2009-11-16 Thread Dominic Steinitz
Dominic Steinitz dominic at steinitz.org writes: Niklas Broberg niklas.broberg at gmail.com writes: please? http://trac.haskell.org/haskell-src-exts Niklas, I'd love to raise a bug for it but unfortunately I can't log on to Good news. Although I couldn't logon as guest, I've created an

Re: [Haskell-cafe] haskell-src-exts Question

2009-11-14 Thread Neil Mitchell
Hi Adding brackets that MUST have been there, by default, sounds like a great idea. The alternative is getting it wrong, so I think that's very safe. Adding brackets that MIGHT have been there is a lot less clear cut. One important consideration is that the fixities you parse/pretty-print with

Re: [Haskell-cafe] haskell-src-exts Question

2009-11-14 Thread Daniel Schüssler
Hi, On Friday 13 November 2009 21:08:42 Neil Mitchell wrote: In HLint I have a bracketing module, which has served me well. Please take any ideas you need from it - http://community.haskell.org/~ndm/darcs/hlint/src/HSE/Bracket.hs . In particular, given a fully bracketed expression, I can call

Re: [Haskell-cafe] haskell-src-exts Question

2009-11-14 Thread Neil Mitchell
Hi Daniel, Funny, I did the opposite approach the other day (not saying either is better :)); that is: parenthesize everything while building the AST (with a wrapper for App) and then: I have utilities in HLint for that too - but I don't want to remove users brackets automatically :-) Btw,

[Haskell-cafe] haskell-src-exts Question

2009-11-13 Thread Dominic Steinitz
I've been generating Haskell using haskell-src-exts but the prettyprinter isn't producing what I would expect. I would expect parse . prettyPrint == id i.e. the AST should be unchanged if you prettyprint it then parse it. Here's an example generated expression: App (App (Var (UnQual (Ident

Re: [Haskell-cafe] haskell-src-exts Question

2009-11-13 Thread Niklas Broberg
Hi Dominic, On Fri, Nov 13, 2009 at 9:49 AM, Dominic Steinitz domi...@steinitz.org wrote: I would have expected the prettyprinter to produce this: pay tPD (a (length tOD + -1)) Do I have to write my own prettyprinter? Do I have to put in explicit parentheses? The latter seems unsatisfactory

Re: [Haskell-cafe] haskell-src-exts Question

2009-11-13 Thread Neil Mitchell
Hi Niklas, Do I have to write my own prettyprinter? Do I have to put in explicit parentheses? The latter seems unsatisfactory as my generated AST is unambiguous and bracketing ought to be part of the prettyprinter. The former would be quite a lot of code as there are many cases to

Re: [Haskell-cafe] haskell-src-exts Question

2009-11-13 Thread Duncan Coutts
On Fri, 2009-11-13 at 20:08 +, Neil Mitchell wrote: Hi Niklas, Do I have to write my own prettyprinter? Do I have to put in explicit parentheses? The latter seems unsatisfactory as my generated AST is unambiguous and bracketing ought to be part of the prettyprinter. The former

Re: [Haskell-cafe] haskell-src-exts Question

2009-11-13 Thread Niklas Broberg
Surely you do want this. It's the biggest problem with the original haskell-src package, that it cannot print out any useful Haskell code obtained from the parser, because it forgets all the brackets. I should point out that haskell-src-exts already fixes this for code obtained from the

Re: [Haskell-cafe] haskell-src-exts Question

2009-11-13 Thread Duncan Coutts
On Fri, 2009-11-13 at 23:54 +0100, Niklas Broberg wrote: Surely you do want this. It's the biggest problem with the original haskell-src package, that it cannot print out any useful Haskell code obtained from the parser, because it forgets all the brackets. I should point out that

[Haskell-cafe] classes question

2009-11-09 Thread Paul Tokarev
doing wrong? Thanks. -- View this message in context: http://old.nabble.com/classes-question-tp26271257p26271257.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http

Re: [Haskell-cafe] classes question

2009-11-09 Thread Ross Mellgren
: http://old.nabble.com/classes-question-tp26271257p26271257.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com . ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] classes question

2009-11-09 Thread Joe Fredette
. -- View this message in context: http://old.nabble.com/classes-question-tp26271257p26271257.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman

Re: [Haskell-cafe] classes question

2009-11-09 Thread Joe Fredette
I run : plus 2 3 I get this error: ERROR - Unresolved overloading *** Type : (Num a, PlusTimes a) = a *** Expression : plus 2 3 What am I doing wrong? Thanks. -- View this message in context: http://old.nabble.com/classes-question-tp26271257p26271257.html Sent from the Haskell - Haskell

Re: [Haskell-cafe] classes question

2009-11-09 Thread Paul Tokarev
- Unresolved overloading *** Type : (Num a, PlusTimes a) = a *** Expression : plus 2 3 What am I doing wrong? Thanks. -- View this message in context: http://old.nabble.com/classes-question-tp26271257p26271257.html Sent from the Haskell - Haskell-Cafe mailing list archive

Re: [Haskell-cafe] classes question

2009-11-09 Thread Ross Mellgren
/classes-question-tp26271257p26271257.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com . ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] question

2009-11-04 Thread Mohamed Ayed
Hi, I want to write a program that will take an AST and a cost vector that represents a cost for each operation and produce a simplified version of the tree based on cost reduction. Can any one give me some ideas ? Thanks ___ Haskell-Cafe mailing

[Haskell-cafe] advice for dispatch question

2009-11-02 Thread John Lato
Hello, I've been thinking about a problem recently, and would like to know if there are any recommendations for a solution. I have two container-like type classes, defined as follows: import Control.Monad type family ElemOf c :: * type family MonadOf c :: * - * class PureContainer c where

[Haskell-cafe] Re: Newcomers question

2009-11-01 Thread b1g3ar5
OK, I understand that now but I've got a supplimentary question. If I put: instance Eq b = Eq (a - b) where (==) = liftA2 (Prelude.==) to do the Eq part I get another error: Couldn't match expected type `Bool' against inferred type `a - Bool' In the expression: liftA2

Re: [Haskell-cafe] Re: Newcomers question

2009-11-01 Thread Alexander Dunlap
, Nov 1, 2009 at 8:09 AM, b1g3ar5 nick.st...@gmail.com wrote: OK, I understand that now but I've got a supplimentary question. If I put: instance Eq b = Eq (a - b) where    (==) = liftA2 (Prelude.==) to do the Eq part I get another error:    Couldn't match expected type `Bool

Re: [Haskell-cafe] Re: Newcomers question

2009-11-01 Thread David Menendez
On Sun, Nov 1, 2009 at 11:09 AM, b1g3ar5 nick.st...@gmail.com wrote: OK, I understand that now but I've got a supplimentary question. If I put: instance Eq b = Eq (a - b) where    (==) = liftA2 (Prelude.==) You don't need the Prelude. here. to do the Eq part I get another error

[Haskell-cafe] Newcomers question

2009-10-31 Thread b1g3ar5
I'm trying: instance Num b = Num (a - b) where fromInteger = pure . Prelude.fromInteger negate = fmap Prelude.negate (+) = liftA2 (Prelude.+) (*) = liftA2 (Prelude.*) abs = fmap Prelude.abs signum = fmap Prelude.signum but the compiler rejects it with: src\Main.hs:24:9: Could not deduce

Re: [Haskell-cafe] Newcomers question

2009-10-31 Thread Henning Thielemann
On Sat, 31 Oct 2009, b1g3ar5 wrote: I'm trying: instance Num b = Num (a - b) where fromInteger = pure . Prelude.fromInteger negate = fmap Prelude.negate (+) = liftA2 (Prelude.+) (*) = liftA2 (Prelude.*) abs = fmap Prelude.abs signum = fmap Prelude.signum but the compiler rejects it with:

Re: [Haskell-cafe] Newcomers question

2009-10-31 Thread Daniel Peebles
For some reason, Show and Eq are superclasses of Num (despite Num not actually using any of their methods), meaning that the compiler forces you to write instances of Eq and Show before it even lets you write a Num instance. I don't think anybody likes this, but I think we're stuck with it for the

[Haskell-cafe] hopefully, a very quick question about ByteString lib

2009-10-27 Thread Iain Barnett
[1 of 1] Compiling Main ( sha1.lhs, interpreted ) import qualified Data.ByteString as B main = B.getLine = B.putStrLn Ok, modules loaded: Main. *Main :main *** Exception: no buffering And just to make sure it's not something to do with GHCi or anything like that main =

Re: [Haskell-cafe] hopefully, a very quick question about ByteString lib

2009-10-27 Thread Thomas DuBuisson
Iain, If you wanted to make sure it didn't have to do with ghci then you should have compiled the original code, not tested different functions. The code you provided works fine compiled and I too am curious what is going on when you run it in ghci. Thomas On Tue, Oct 27, 2009 at 8:26 AM, Iain

Re: [Haskell-cafe] hopefully, a very quick question about ByteString lib

2009-10-27 Thread Daniel Fischer
Am Dienstag 27 Oktober 2009 16:47:12 schrieb Thomas DuBuisson: Iain, If you wanted to make sure it didn't have to do with ghci then you should have compiled the original code, not tested different functions. The code you provided works fine compiled and I too am curious what is going on when

Re: [Haskell-cafe] hopefully, a very quick question about ByteString lib

2009-10-27 Thread Iain Barnett
On 27 Oct 2009, at 15:47, Thomas DuBuisson wrote: If you wanted to make sure it didn't have to do with ghci then you should have compiled the original code, not tested different functions. That is a very good point! On 27 Oct 2009, at 16:00, Daniel Fischer wrote: Look at the sources:

Re: [Haskell-cafe] hopefully, a very quick question about ByteString lib

2009-10-27 Thread Duncan Coutts
On Tue, 2009-10-27 at 17:00 +0100, Daniel Fischer wrote: Look at the sources: hGetLine :: Handle - IO ByteString hGetLine h = wantReadableHandle Data.ByteString.hGetLine h $ \ handle_ - do case haBufferMode handle_ of NoBuffering - error no buffering _other -

Re: [Haskell-cafe] hopefully, a very quick question about ByteString lib

2009-10-27 Thread Don Stewart
duncan.coutts: On Tue, 2009-10-27 at 17:00 +0100, Daniel Fischer wrote: Look at the sources: hGetLine :: Handle - IO ByteString hGetLine h = wantReadableHandle Data.ByteString.hGetLine h $ \ handle_ - do case haBufferMode handle_ of NoBuffering - error no buffering

[Haskell-cafe] bit of a noob question

2009-10-24 Thread spot135
Ok maybe a noob question, but hopefully its an easy one. This is what I've got so far: test :: x-[a] - (b,[b]) test x arrlist = let test1 = x a = filter (\n - fst n == test1) arrlist test2 = map snd a in (test1, [test2

Re: [Haskell-cafe] bit of a noob question

2009-10-24 Thread Daniel Fischer
Am Sonntag 25 Oktober 2009 00:27:50 schrieb spot135: Ok maybe a noob question, but hopefully its an easy one. This is what I've got so far: test :: x-[a] - (b,[b]) That can't be. The implementation below has type Eq a = a - [(a,b)] - (a,[b]) test x arrlist = let test1 = x

Re: [Haskell-cafe] bit of a noob question

2009-10-24 Thread spot135
Daniel Fischer-4 wrote: Am Sonntag 25 Oktober 2009 00:27:50 schrieb spot135: Ok maybe a noob question, but hopefully its an easy one. This is what I've got so far: test :: x-[a] - (b,[b]) That can't be. The implementation below has type Eq a = a - [(a,b)] - (a,[b]) test x

Re: [Haskell-cafe] bit of a noob question

2009-10-24 Thread Jeremy Shaw
),('b',2)] test2 :: (Ord a) = [(a, b)] - [(a, [b])] test2 l = map (\grp - (fst (head grp), map snd grp)) ((groupBy ((==) `on` fst)) l) ex2 = test [('a',1),('a',2),('a',3),('b',1),('b',2)] On Oct 24, 2009, at 5:27 PM, spot135 wrote: Ok maybe a noob question, but hopefully its an easy

Re: [Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-20 Thread minh thu
[snip] Not a hack, a solution. A consistent one. Look: (`foldl` 0) (`-` 2) Don't they look exactly the same? [snip] These look the same too (and *are* consistent): (f a b) (+ a b) But it's not Haskell.. IMO conflating binary minus and unary minus is not consistent. Something I wonder

[Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-20 Thread oleg
Something I wonder from time to time if it would be a good thing or not is to allow a `f g` b to mean f g a b You don't have to wonder: http://www.haskell.org/haskellwiki/Infix_expressions Granted, you have to use different characters rather than the backquote. On the other

[Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-20 Thread Will Ness
Jason Dagit dagit at codersbase.com writes: On Mon, Oct 19, 2009 at 5:53 PM, Will Ness will_n48 at yahoo.com wrote: You think of functions, where domain matters (for purists?). In syntax only the result matter, does it read? Does it have an intended meaning? How is it a mistake if it

Re: [Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-20 Thread Richard O'Keefe
It's worth remembering that APL and SML, amongst others, distinguish between the sign used for a negative literal (¯1 in APL, ~1 in SML) and the sign used for subtraction (the hyphen/minus in both of them). It doesn't seem to be a hard thing to get your head around in practice. From having

Re: [Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-20 Thread wren ng thornton
minh thu wrote: Something I wonder from time to time if it would be a good thing or not is to allow a `f g` b to mean f g a b This comes up from time to time, though it is often met with stern disapproval because it can easily lead to loss of clarity. There is a valid alternative, though

[Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-19 Thread Will Ness
wren ng thornton wren at freegeek.org writes: Will Ness wrote: (`foldl`2) works. (`-`2) should too. The `` syntax is for converting lexical identifiers into infix operators. Symbolic identifiers are already infix, which is why `` So it would be a no-op then. Why make it

Re: [Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-19 Thread Tom Tobin
On Mon, Oct 19, 2009 at 5:34 PM, Will Ness will_...@yahoo.com wrote: This syntax already exists. The '`' symbol is non-collating already, so using it for symbol chars doesn't change anything (it's not that it can be a part of some name, right?). To turn an infix op into an infix op is an id

[Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-19 Thread Will Ness
Tom Tobin korpios at korpios.com writes: On Mon, Oct 19, 2009 at 5:34 PM, Will Ness will_n48 at yahoo.com wrote: This syntax already exists. The '`' symbol is non-collating already, so using it for symbol chars doesn't change anything (it's not that it can be a part of some name,

Re: [Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-19 Thread wren ng thornton
Will Ness wrote: wren ng thornton writes: Attack the underlying problem, don't introduce hacks to cover up broken hacks. This isn't C++. The underlying problem is a broken scanner where it can't distinguish between a binary op and a number read syntax. The underlying problem is that (1)

Re: [Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-19 Thread Jason Dagit
On Mon, Oct 19, 2009 at 5:53 PM, Will Ness will_...@yahoo.com wrote: Tom Tobin korpios at korpios.com writes: On Mon, Oct 19, 2009 at 5:34 PM, Will Ness will_n48 at yahoo.com wrote: This syntax already exists. The '`' symbol is non-collating already, so using it for symbol chars

Re: [Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-19 Thread Luke Palmer
On Sun, Oct 18, 2009 at 5:31 PM, Will Ness will_...@yahoo.com wrote: Luke Palmer lrpalmer at gmail.com writes: Or you could use the subtract function.   map (subtract 2) [3,4,5]   [1,2,3] I don't want to. I think at about this point, this stopped being an intellectual discussion.

[Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-18 Thread Will Ness
Gregory Propf gregorypropf at yahoo.com writes: I actually meant it as sort of a joke but maybe it's not after all. Seriously though, using anything non-ASCII in source code is a bad idea, because there are lots of fonts and editors in the world. It seems natural to me to have (`-`2)

Re: [Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-18 Thread Luke Palmer
On Sun, Oct 18, 2009 at 4:47 PM, Will Ness will_...@yahoo.com wrote: Gregory Propf gregorypropf at yahoo.com writes: I actually meant it as sort of a joke but maybe it's not after all. Seriously though, using anything non-ASCII in source code is a bad idea, because there are lots of fonts

[Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-18 Thread Will Ness
Luke Palmer lrpalmer at gmail.com writes: Or you could use the subtract function. map (subtract 2) [3,4,5] [1,2,3] I don't want to. I don't think syntax sugar is worth it in this case. I do. Operators are great because they make our intent visible, immediately apparent. Long

Re: [Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-18 Thread wren ng thornton
Will Ness wrote: Luke Palmer lrpalmer at gmail.com writes: Or you could use the subtract function. map (subtract 2) [3,4,5] [1,2,3] I don't want to. I don't think syntax sugar is worth it in this case. I do. Operators are great because they make our intent visible, immediately

beginner question

2009-10-14 Thread Luca Ciciriello
Just a Haskell beginner question. If I load in GHCi the code below all works fine, I load a file and its content is shown on screen. But if I use the second version of my load_by_key (the commented one) no error is reported loading and executing this code, but nothing is shown on screen

Re: beginner question

2009-10-14 Thread Philip K.F.
) hClose (\h - hGetContents h = cont) Hope this helps. By the way, this type of question should probably go to haskell-c...@haskell.org which will usually give you a lot of explanation quite quickly. Regards, Philip [1] http://haskell.org/ghc/docs/latest/html

Re: beginner question

2009-10-14 Thread Daniel Fischer
Am Mittwoch 14 Oktober 2009 08:26:10 schrieb Luca Ciciriello: Just a Haskell beginner question. This sort of generic question has a higher probability of receiving a quick answer on haskell-c...@haskell.org or beginn...@haskell.org, where more people are reading. If I load in GHCi the code

RE: beginner question

2009-10-14 Thread Luca Ciciriello
Thanks Philip and Daniel for your help. Your explanation is clear. Thanks also for direct me on the right news letters :-) Luca. _ Chat to your friends for free on selected mobiles

[Haskell-cafe] QuickCheck2 question

2009-10-12 Thread Patrick Perry
I'm having some trouble with QuickCheck2 and Control.Applicative. Specifically, I have the following functions (slightly simplified): copyVector :: IOVector - Vector - IO () freezeVector :: IOVector - IO (Vector) I have a test, part of which looks like monadicIO $ do run $

Re: [Haskell-cafe] type inference question

2009-10-09 Thread wren ng thornton
Cristiano Paris wrote: On Thu, Oct 8, 2009 at 12:48 PM, Lennart Augustsson wrote: The reason a gets a single type is the monomorphism restriction (read the report). Using NoMonomorphismRestriction your example with a works fine. Could you explain why, under NoMonomorphismRestriction, this

Re: [Haskell-cafe] type inference question

2009-10-09 Thread minh thu
2009/10/9 wren ng thornton w...@freegeek.org: Cristiano Paris wrote: On Thu, Oct 8, 2009 at 12:48 PM, Lennart Augustsson wrote: The reason a gets a single type is the monomorphism restriction (read the report). Using NoMonomorphismRestriction your example with a works fine. Could you

[Haskell-cafe] type inference question

2009-10-08 Thread minh thu
Hi, I'd like to know what are the typing rules used in Haskell (98 is ok). Specifically, I'd like to know what makes let i = \x - x in (i True, i 1) legal, and not let a = 1 in (a + (1 :: Int), a + (1.0 :: Float)) Is it correct that polymorphic functions can be used polymorphically (in

Re: [Haskell-cafe] type inference question

2009-10-08 Thread Martijn van Steenbergen
minh thu wrote: Also, I'd like to know why id id True is permitted but not (\f - f f True) id Because this requires rank-2 types: Prelude :set -XScopedTypeVariables Prelude :set -XRank2Types Prelude (\(f :: forall a. a - a) - f f True) id True HTH, Martijn.

Re: [Haskell-cafe] type inference question

2009-10-08 Thread Jochem Berndsen
minh thu wrote: Also, I'd like to know why id id True is permitted but not (\f - f f True) id If you want to do this, answer the question what is the type of (\f - f f True)? You can do this, by the way, using rank-2 types: {-# LANGUAGE Rank2Types, PatternSignatures #-} thisIsAlwaysTrue

Re: [Haskell-cafe] random question

2009-10-08 Thread Nicolas Pouillard
Excerpts from Bryan O'Sullivan's message of Wed Oct 07 23:25:10 +0200 2009: On Wed, Oct 7, 2009 at 1:59 PM, Michael Mossey m...@alumni.caltech.eduwrote: My thread about randomness got hijacked so I need to restate my remaining question here. Is it acceptable to write pure routines that use

Re: [Haskell-cafe] type inference question

2009-10-08 Thread minh thu
2009/10/8 Jochem Berndsen joc...@functor.nl: minh thu wrote: Also, I'd like to know why id id True is permitted but not (\f - f f True) id If you want to do this, answer the question what is the type of (\f - f f True)? You can do this, by the way, using rank-2 types: {-# LANGUAGE

<    7   8   9   10   11   12   13   14   15   16   >