Re: [Haskell-cafe] Is take behaving correctly?

2007-09-13 Thread rahn
pref_eq k xs ys = take k xs == take k ys This seems to be a straightforward implementation with good properties. Actually, no, at least not if implemented naively. I choosed this example, since I stumbled on this question last week. Reputable mathematicians doing combinatorics on

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-13 Thread Jules Bean
Neil Mitchell wrote: Hi A more serious point is that in some cases we might want take to underapproximate, or zip to truncate (or tail [] = [] ?). I don't think there's always a clear library choice here. I have a zipWithEq function I often use, which crashes if the zip'd lists aren't equal.

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-13 Thread Neil Mitchell
Hi Although I appluad the semantics of the safe package, I'm not delighted with the idea of replacing our concise elegant standard library names with uglyAndRatherLongCamelCaseNamesThatCouldBePerlOrEvenJava though. Conciseness of expression is a virtue. They aren't that long - merely an

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-13 Thread Jules Bean
Neil Mitchell wrote: Hi Although I appluad the semantics of the safe package, I'm not delighted with the idea of replacing our concise elegant standard library names with uglyAndRatherLongCamelCaseNamesThatCouldBePerlOrEvenJava though. Conciseness of expression is a virtue. They aren't that

[Haskell-cafe] Re: getting crazy with character encoding

2007-09-13 Thread Stephane Bortzmeyer
On Thu, Sep 13, 2007 at 12:23:33AM +, Aaron Denney [EMAIL PROTECTED] wrote a message of 76 lines which said: the characters read and written should correspond to the native environment notions and encodings. These are, under Unix, determined by the locale system. Locales, while fine

Re[2]: [Haskell-cafe] Re: getting crazy with character encoding

2007-09-13 Thread Bulat Ziganshin
Hello Stefan, Thursday, September 13, 2007, 4:40:17 AM, you wrote: I'm pretty sure Hugs does the right thing. NHC is probably broken. In any case, we already have hGetBuf / hPutBuf in the standard base libaries for raw binary IO, so code that uses getChar for bytes really has no excuse. We

Re: [Haskell-cafe] Re: getting crazy with character encoding

2007-09-13 Thread Andrea Rossato
On Thu, Sep 13, 2007 at 11:07:03AM +0200, Stephane Bortzmeyer wrote: On Thu, Sep 13, 2007 at 12:23:33AM +, Aaron Denney [EMAIL PROTECTED] wrote a message of 76 lines which said: the characters read and written should correspond to the native environment notions and encodings.

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-13 Thread Ketil Malde
On Thu, 2007-09-13 at 09:56 +0100, Jules Bean wrote: Neil Mitchell wrote: Hi Although I appluad the semantics of the safe package, I'm not delighted with the idea of replacing our concise elegant standard library names with uglyAndRatherLongCamelCaseNamesThatCouldBePerlOrEvenJava

Re: [Haskell-cafe] Monad.Reader 8: Haskell, the new C++

2007-09-13 Thread Pepe Iborra
On 13/09/2007, at 0:06, Don Stewart wrote: ok: In Monad.Reader 8, Conrad Parker shows how to solve the Instant Insanity puzzle in the Haskell type system. Along the way he demonstrates very clearly something that was implicit in Mark Jones' Type Classes with Functional Dependencies paper

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-13 Thread Neil Mitchell
Hi Similarly, I expect foo and foo' to be equivalent, except for strictness properties, but perhaps an underscore could be used for slightly different behaviors (interpretations, as it were)? tail_ or zip_, anyone? There are 4 variants of tail: tail :: [a] - [a] -- normal tailDef :: [a] -

Re: [Haskell-cafe] Re: getting crazy with character encoding

2007-09-13 Thread Ketil Malde
On Wed, 2007-09-12 at 17:40 -0700, Stefan O'Rear wrote: On Thu, Sep 13, 2007 at 12:23:33AM +, Aaron Denney wrote: Unfortunately, at this point it is a well entrenched bug, and changing the behaviour will undoubtedly break programs. ... There should be another system for getting the

[Haskell-cafe] Re: getting crazy with character encoding

2007-09-13 Thread Aaron Denney
On Thu, Sep 13, 2007 at 11:07:03AM +0200, Stephane Bortzmeyer wrote: On Thu, Sep 13, 2007 at 12:23:33AM +, Aaron Denney [EMAIL PROTECTED] wrote a message of 76 lines which said: the characters read and written should correspond to the native environment notions and encodings.

RE: Re[2]: [Haskell-cafe] Basic FFI with GHC

2007-09-13 Thread Simon Peyton-Jones
| So, after more searching on the internet and some RTFM, I think I | found my answer, and it seems to work, but I don't know if it's the | right answer to generalize from. | | i have added your recipe to http://www.haskell.org/haskellwiki/FFI_cook_book Thank you Bulat. There's also a GHC

[Haskell-cafe] Re: help getting happy

2007-09-13 Thread Simon Marlow
Greg Meredith wrote: Haskellians, The code pasted in below causes Happy to return parE when invoked with happy rparse.y -i . Is there anyway to get Happy to give me just a wee bit more info as to what might be causing the parE (which i interpret a 'parse error'). Please grab a more recent

Re[4]: [Haskell-cafe] Basic FFI with GHC

2007-09-13 Thread Bulat Ziganshin
Hello Simon, Thursday, September 13, 2007, 2:12:18 PM, you wrote: http://www.haskell.org/haskellwiki/FFI_cook_book There's also a GHC page about the FFI here: http://haskell.org/haskellwiki/GHC/Using_the_FFI this page, despite its name, is only about dealing with Visual C++ via

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-13 Thread Jeff Polakow
Hello, There are 4 variants of tail: tail :: [a] - [a] -- normal tailDef :: [a] - [a] - [a] -- returns the first argument on [] tailMay :: [a] - Maybe [a] -- returns a Nothing tailNote :: String - [a] - [a] -- crashes, but with a helpful message tailSafe :: [a] - [a] -- returns [] on []

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-13 Thread Neil Mitchell
Hi Is there a reason for not having tailM :: Monad m = [a] - m [a] which, at least for me, is much more useful? No, that probably is a much more sensible choice. Patches welcome :) Thanks Neil ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-13 Thread Lutz Donnerhacke
* Neil Mitchell wrote: There are 4 variants of tail: tail :: [a] - [a] -- normal tailDef :: [a] - [a] - [a] -- returns the first argument on [] tailMay :: [a] - Maybe [a] -- returns a Nothing tailNote :: String - [a] - [a] -- crashes, but with a helpful message tailSafe :: [a] - [a] --

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-13 Thread Neil Mitchell
Hi From the logical point of view tailMay is the right one. It pushes the error handling to the caller programm. tail = fromJust . tailMay The error messages suffer: tail [] = error: fromJust Nothing That's why I supplied tailNote, where tailNote foo broke its invariant! [] gives the

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-13 Thread Jules Bean
Jeff Polakow wrote: Hello, There are 4 variants of tail: tail :: [a] - [a] -- normal tailDef :: [a] - [a] - [a] -- returns the first argument on [] tailMay :: [a] - Maybe [a] -- returns a Nothing tailNote :: String - [a] - [a] -- crashes, but with a helpful message tailSafe ::

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-13 Thread Ketil Malde
On Thu, 2007-09-13 at 13:56 +0100, Neil Mitchell wrote: tail = fromJust . tailMay The error messages suffer [..] That's why I supplied tailNote Still, given tailMay, we have: tailDef xs = maybe xs id . tailMay tailNote msg = tailDef (error msg) tailSafe = tailDef [] tail =

Re: [Haskell-cafe] Re: getting crazy with character encoding

2007-09-13 Thread Stefan O'Rear
On Thu, Sep 13, 2007 at 12:06:15PM +0200, Ketil Malde wrote: On Wed, 2007-09-12 at 17:40 -0700, Stefan O'Rear wrote: On Thu, Sep 13, 2007 at 12:23:33AM +, Aaron Denney wrote: Unfortunately, at this point it is a well entrenched bug, and changing the behaviour will undoubtedly break

Re: [Haskell-cafe] Monad.Reader 8: Haskell, the new C++

2007-09-13 Thread Pepe Iborra
For a taste, see Instant Insanity transliterated in this functional language: http://hpaste.org/2689 I thought I'd better paste here the code for Instant Insanity with Type Families. Otherwise it will vanish in a short time. I took the opportunity to clean it up a bit. Although AT are

Re: [Haskell-cafe] Re: getting crazy with character encoding

2007-09-13 Thread David Roundy
On Thu, Sep 13, 2007 at 06:49:59AM -0700, Stefan O'Rear wrote: On Thu, Sep 13, 2007 at 12:06:15PM +0200, Ketil Malde wrote: On Wed, 2007-09-12 at 17:40 -0700, Stefan O'Rear wrote: On Thu, Sep 13, 2007 at 12:23:33AM +, Aaron Denney wrote: Unfortunately, at this point it is a well

[Haskell-cafe] Memory leak or wrong use of Array ?

2007-09-13 Thread L.Guo
Hi MailList Haskell-Cafe: I am tring to solve Project Euler problem 70. And write some code. (will at the end of this mail) And, I run the code in GHCi. The problem is that, when the input is 1,000,000, it works fine, when the input is up to 10,000,000, the memory GHCi used increase very fast

[Haskell-cafe] Re: help getting happy

2007-09-13 Thread Greg Meredith
Simon, Cheers. i solved the problem before i saw your email. The Happy i got was a result of invoking port install happy What's the drift between macports and happy versions? Is there a way of using Happy without being on or even near the cutting edge of development? Best wishes, --greg On

Re: [Haskell-cafe] Re: help getting happy

2007-09-13 Thread Paul Brown
On 9/13/07, Greg Meredith [EMAIL PROTECTED] wrote: Cheers. i solved the problem before i saw your email. The Happy i got was a result of invoking port install happy What's the drift between macports and happy versions? Is there a way of using Happy without being on or even near the cutting

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-13 Thread Andrew Coppin
Jules Bean wrote: I'm not delighted with the idea of replacing our concise elegant standard library names with uglyAndRatherLongCamelCaseNamesThatCouldBePerlOrEvenJava though. Conciseness of expression is a virtue. I, on the other hand, I'm not delighted with names such as Eq and Ord.

Re: [Haskell-cafe] Monad.Reader 8: Haskell, the new C++

2007-09-13 Thread Don Stewart
Better here means better -- a functional language on the type system, to type a functional language on the value level. -- Don For a taste, see Instant Insanity transliterated in this functional language: http://hpaste.org/2689 NB: it took me 5 minutes, and that was my first

[Haskell-cafe] MonadGL - Partitioning effects without giving up type inference

2007-09-13 Thread Jules Bean
The OpenGL bindings which come bundled with ghc are a really great example of how even an almost-literal port of a C API can still be easier to work with in haskell than it is in C, because of the benefits of type inference and powerful abstractions. Even the ability to mapM_ is a tool to make C

Re: [Haskell-cafe] haskell and reflection

2007-09-13 Thread Don Stewart
lgreg.meredith: Haskellians, Am i wrong in my assessment that the vast majority of reflective machinery is missing from Haskell? Specifically, * there is no runtime representation of type available for programmatic representation * there is no runtime

[Haskell-cafe] Vital for real Haskell?

2007-09-13 Thread Peter Verswyvelen
I showed Vital (http://www.cs.kent.ac.uk/projects/vital) to some teachers at my university and they where really enthousiastic. IMHO the Haskell community needs something like this, but for *real* Haskell (preferable with extensions), and not using Java... Is any work being done on something

Re: [Haskell-cafe] Building production stable software in Haskell

2007-09-13 Thread J. Garrett Morris
I believe that rnf from the Control.Parallel.Strategies library shipped with GHC 6.6.1 is equivalent to deepSeq, as in: x `deepSeq` yis equivalent to rnf x `seq` y Isn't it? /g On 9/12/07, Peter Verswyvelen [EMAIL PROTECTED] wrote: Thanks for all the info. It's really good news that

Re: [Haskell-cafe] Monad.Reader 8: Haskell, the new C++

2007-09-13 Thread Peter Verswyvelen
This is all very cool stuff, but sometimes I wander if it isn't possible to drop the special languages for fiddling with types, and introduce just a single language which has no types, only raw data from which you can built your own types (as in the old days when we used macro assemblers ;-),

Re: [Haskell-cafe] Monad.Reader 8: Haskell, the new C++

2007-09-13 Thread Derek Elkins
On Thu, 2007-09-13 at 11:12 -0700, Don Stewart wrote: Better here means better -- a functional language on the type system, to type a functional language on the value level. -- Don For a taste, see Instant Insanity transliterated in this functional language:

Re: [Haskell-cafe] MonadGL - Partitioning effects without giving up type inference

2007-09-13 Thread Derek Elkins
On Thu, 2007-09-13 at 19:34 +0100, Jules Bean wrote: Any comments? I'm sure this has been shown before but I don't remember where. The Monad Transformer Library essentially does this, the types you get are along the lines of: foo :: (Monad m, MonadState s m, MonadReader r m) = m Int

Re: [Haskell-cafe] Monad.Reader 8: Haskell, the new C++

2007-09-13 Thread ok
I wrote: Since not all Turing machines halt, and since the halting problem is undecidable, this means not only that some Haskell programs will make the type checker loop forever, but that there is no possible meta- checker that could warn us when that would happen. On 13 Sep 2007, at 4:27 pm,

[Haskell-cafe] haskell on llvm?

2007-09-13 Thread brad clawsie
has anyone ever considered using llvm as a infrastructure for haskell compilation? it wold seem people are looking at building frontends for scheme, ocaml, etc. i don't know if an alternate backend is appropriate, but it would seem to be an interesting way to aggregate the best thinking for

Re: [Haskell-cafe] Monad.Reader 8: Haskell, the new C++

2007-09-13 Thread Thomas Schilling
On Fri, 2007-09-14 at 10:42 +1200, ok wrote: I wrote: Since not all Turing machines halt, and since the halting problem is undecidable, this means not only that some Haskell programs will make the type checker loop forever, but that there is no possible meta- checker that could warn us

Re: [Haskell-cafe] haskell on llvm?

2007-09-13 Thread Thomas Schilling
On Thu, 2007-09-13 at 15:58 -0700, Don Stewart wrote: clawsie: has anyone ever considered using llvm as a infrastructure for haskell compilation? it wold seem people are looking at building frontends for scheme, ocaml, etc. i don't know if an alternate backend is appropriate, but it would

Re: [Haskell-cafe] haskell on llvm?

2007-09-13 Thread Thomas Schilling
On Thu, 2007-09-13 at 15:55 -0700, brad clawsie wrote: has anyone ever considered using llvm as a infrastructure for haskell compilation? it wold seem people are looking at building frontends for scheme, ocaml, etc. i don't know if an alternate backend is appropriate, but it would seem to be

RE: [Haskell-cafe] Vital for real Haskell?

2007-09-13 Thread Tim Docker
Pivotal was/is Vital's successor: http://www.cs.kent.ac.uk/projects/pivotal/ However, it's not clear from the website how alive the project is. I'd love to see a robust implementation of something like this. Tim -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]

Re: [Haskell-cafe] getting crazy with character encoding

2007-09-13 Thread John Meacham
On Wed, Sep 12, 2007 at 05:19:22PM +0200, Andrea Rossato wrote: And so it's my job to convert it in what I need. Luckily I've just discovered (and now I'm reading) some of John Meacham's code on locale. This is going to be very helpful (unfortunately I don't see Licenses coming with HsLocale,

Re: [Haskell-cafe] Monad.Reader 8: Haskell, the new C++

2007-09-13 Thread Manuel M T Chakravarty
Pepe Iborra wrote, For a taste, see Instant Insanity transliterated in this functional language: http://hpaste.org/2689 I thought I'd better paste here the code for Instant Insanity with Type Families. Otherwise it will vanish in a short time. I took the opportunity to clean it up a bit.

Re: [Haskell-cafe] Monad.Reader 8: Haskell, the new C++

2007-09-13 Thread Manuel M T Chakravarty
Derek Elkins wrote, On Thu, 2007-09-13 at 11:12 -0700, Don Stewart wrote: Better here means better -- a functional language on the type system, to type a functional language on the value level. -- Don For a taste, see Instant Insanity transliterated in this functional language:

Re: [Haskell-cafe] MonadGL - Partitioning effects without giving up type inference

2007-09-13 Thread Stuart Cook
On 9/14/07, Jules Bean [EMAIL PROTECTED] wrote: {-# OPTIONS -fglasgow-exts #-} (extensions are only for deriving (Monad), it's not important) If that's the case, you should be able to write (assuming GHC 6.6+) {-# LANGUAGE GeneralizedNewtypeDeriving #-} though I don't know how well other

Re: [Haskell-cafe] Monad.Reader 8: Haskell, the new C++

2007-09-13 Thread Stefan O'Rear
On Fri, Sep 14, 2007 at 11:05:34AM +1000, Manuel M T Chakravarty wrote: Just to complete transferring the discussion from the ephemeral hpaste to the mailing list. My response to the lack of being able to display normalised types was that GHC actually goes to considerable trouble to

Re: [Haskell-cafe] Monad.Reader 8: Haskell, the new C++

2007-09-13 Thread Thomas Conway
On 9/14/07, Thomas Schilling [EMAIL PROTECTED] wrote: The type system doesn't help you avoid writing non-terminating programs, so i see no problem with it being possible giving programmers the power to express and check more complex properties of their programs -- as long as type-checking

[Haskell-cafe] Re: getting crazy with character encoding

2007-09-13 Thread Aaron Denney
On 2007-09-13, Stefan O'Rear [EMAIL PROTECTED] wrote: In any case, we already have hGetBuf / hPutBuf in the standard base libaries for raw binary IO, so code that uses getChar for bytes really has no excuse. Except, of course, that hGetBuf and hPutBuf are (a) allocating the memory for the

[Haskell-cafe] Clarification Please

2007-09-13 Thread PR Stanley
Hi Taken from chapter 6, section 8 of the Hutton book on programming in Haskell: 5. Using merge, define a recursive function msort :: (Ord a) = [a] - [a] that implements merge sort, in which the empty list and singleton lists are already sorted, and any other list is sorted by merging together

Re: [Haskell-cafe] Clarification Please

2007-09-13 Thread Michael Vanier
Define a merge function that merges two sorted lists into a sorted list containing all the elements of the two lists. Then define the msort function, which will be recursive. Mike PR Stanley wrote: Hi Taken from chapter 6, section 8 of the Hutton book on programming in Haskell: 5. Using

Re: [Haskell-cafe] Clarification Please

2007-09-13 Thread PR Stanley
I'm not sure. We start with one list and also, perhaps I should have mentioned that I have a merge function which takes two sorted lists with similar, now, what do they call it, similar orientation? and merges them into one sorted list. e.g. merge [1, 4,] [2, 3] [1,2,3,4] Cheers, Paul At

Re: [Haskell-cafe] Clarification Please

2007-09-13 Thread Michael Vanier
OK, you have the split function, and you have the merge function, and now you have to define the msort function. First write down the base cases (there are two, as you mention), which should be obvious. Then consider the remaining case. Let's say you split the list into two parts. Then what

Re: [Haskell-cafe] Clarification Please

2007-09-13 Thread Krzysztof Kościuszkiewicz
On Fri, Sep 14, 2007 at 03:45:02AM +0100, PR Stanley wrote: 5. Using merge, define a recursive function msort :: (Ord a) = [a] - [a] that implements merge sort, in which the empty list and singleton lists are already sorted, and any other list is sorted by merging together the two lists