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
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.
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
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
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
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
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.
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
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
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] -
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
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.
| 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
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
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
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 []
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
* 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] --
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
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 ::
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 =
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
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
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
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
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
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
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.
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
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
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
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
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
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 ;-),
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:
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
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,
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
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
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
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
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]
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,
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.
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:
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
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
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
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
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
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
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
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
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
54 matches
Mail list logo