John Wicket wrote:
On 9/24/07, Sam Hughes [EMAIL PROTECTED] wrote:
John Wicket wrote:
I am still in an imperative way of thinking. In this example here; how
would I call putStrLn and then set the function with a value. Eg:
aa :: String - IO ()
aa instr = do
putStrLn abc
putStrLn abc
On Sun, 2007-09-23 at 21:17 -0400, David Menendez wrote:
My point was that I'm not aware of any packaging systems that don't
have a global installed/not installed bit for each package, which
isn't suited to handling Haskell libraries.
I don't agree - you are assuming there is a one to one
John Wicket wrote:
Sorry, I was actually trying to use this as an example for something
more complicated I am trying to do. In this example, why would the
inferred type be IO ()
aa :: String - String
aa instr = do
putStrLn abc
putStrLn abc
return Az
Couldn't match expected type
Greetings.
Anybody happen to know what the time complexity of transpose is?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
On 9/24/07, Andrew Coppin [EMAIL PROTECTED] wrote:
Anybody happen to know what the time complexity of transpose is?
Looking at the definition of 'transpose' in:
http://darcs.haskell.org/libraries/base/Data/List.hs:
transpose :: [[a]] - [[a]]
transpose [] = []
transpose
Andrea Rossato wrote:
I'm not even sure if this message will get through. Actually this is
the only mailing list I have some problem with... perhaps some filter
may be considering my messages as spam. I'd like to have a copy of
that filter installed on my system!
I saw it. In total, four
john lask wrote:
test1 = readFile big.dat = (\x-print $ parse x)
test2 = readFile big.dat = (\x-print $ fst $ parse x)
test1 (on a large file) will succeed in ghc but fail in hugs
test2 on same file will succeed in both ghc and hugs
big.dat is just some large data file say 1MB.
(not
I agree with your analysis.
if the following is tried in hugs then ghc you will obtain two different
results..
return (repeat 'a') = \ x - print $ span (const True) x
with hugs you will get a stack error, in ghc it executes in constant space,
i.e. indefinitely. In essenece the above example
On Sat, 22 Sep 2007, Peter Verswyvelen wrote:
Hi,
in SOE, the following memoization function is implemented:
memo1 :: (a-b) - (a-b)
memo1 f = unsafePerformIO $ do
cache - newIORef []
return $ \x - unsafePerformIO $ do
vals - readIORef cache
case x `inCache` vals of
On Sun, 23 Sep 2007, Thomas Conway wrote:
In Prelude there is a function properFraction which splits a RealFrac
into its integer part and its fractional part. You can use this to
implement fmod. Assuming properFraction is efficient (which it
probably isn't), you can implement fmod really quite
[cc-ed to haskell@, as this discussion is about [EMAIL PROTECTED]
There are four things sent to the haskell list@
1) Calls for papers
2) Annoucements
3) Oleg's stuff (which are really announcements of a library or technique)
4) Off topic stuff
I'm initially only proposing to mop up category
return (repeat 'a') = \ x - print $ span (const True) x
with hugs you will get a stack error, in ghc it executes in constant space,
i.e. indefinitely. In essenece the above example does exactly the same as my
ealier code.
this thread might be relevant:
I don't know, me newbie, you expert ;-) I just pasted the code from the
SOE website.
But note that it is using pointers to the infinite lists to avoid comparing
them by content (which wouldn't work, since they're infinite), so it has to
use unsafePerformIO no?
inCache :: a - [(a,b)] - Maybe b
x
On Mon, 24 Sep 2007, John Wicket wrote:
I am still in an imperative way of thinking. In this example here; how
would I call putStrLn and then set the function with a value. Eg:
aa :: String - IO ()
aa instr = do
putStrLn abc
putStrLn abc
return 123
The article
Andrew Coppin:
Anybody happen to know what the time complexity of transpose is?
Bas van Dijk:
The worst case time complexity is O(r*c) where 'r' are the number of
rows and 'c' are the number of columns.
I believe Bas is correct, though it might be worth elaborating on what
he means by worst
David Menendez wrote:
Using Cabal directly, I can simply run the configure/build/install
process three times with different configuration options.
Is this possible with systems like RPM/apt/port/etc?
Yes. In the case of RPM and dpkg, we prefix a library's name with the
name and version of
On Mon, Sep 24, 2007 at 01:00:40PM +0100, Claus Reinke wrote:
in other words, people were meant to subscribe either
to haskell or to haskell+haskell-cafe, and posting to
haskell was meant to be a flag able to raise a topic
briefly over the general din in haskell-cafe.
Do people think that
afraid not
the given example is too strict, the requirement is to generate the matched
portion lazilly, and return the tail (unconsumed portion).
In principle the function should be capable of being written to run in
constant space which the given example dose not.
From: Claus Reinke
On 9/23/07, Neil Mitchell [EMAIL PROTECTED] wrote:
* Rename haskell@ to haskell-announce@, and redirect mails from haskell@
to haskell-announce@ for some period.
Makes sense to me. Seems to reflect the emails I'm actually getting
from the lists in question.
Hi
Forgive me, but I would much prefer a newsgroup to a mailing list.
True, I could unsubscribe now and just browse the mailman archives -
but for posting, I'd have to temporarily re-subscribe, which is awkward.
(Indeed that's the only reason I'm not doing it.)
I believe you can post from
Sorry guys for joining the thread of sinners on haskell@ today. Forgot to check
if guests had not moved to cafe;-)
It is a good example though how insufficient this verbal principles are, since I
have myself raised the need to revise names of the lists here.
On second thought, with rising
in other words, people were meant to subscribe either
to haskell or to haskell+haskell-cafe, and posting to
haskell was meant to be a flag able to raise a topic
briefly over the general din in haskell-cafe.
Do people think that is working?
i don't think it is working anymore. haskell-cafe
Well aa isn't returning a string. It's returning a function for
later evaluation which encapsulates the string. It's like
driving anywhere in California. You can't get there following
the road signs unless you've driven there once before. In this
case the road signs say return a string but
afraid not
the given example is too strict, the requirement is to generate the matched
portion lazilly, and return the tail (unconsumed portion).
ah yes, without optimisations, Prelude.span builds up stack,
while the continuation-based alternative i mentioned is too
strict for some uses.
In
I'm spending my Copious Free Time going through the
Graham/Knuth/Patashnik _Concrete Mathematics_ textbook. This is the
textbook used at one of Stanford's on-beyond-calculus math for CS
majors classes.
If nothing else, the discipline of doing the homework problems at the
end of each chapter
Claus Reinke wrote:
the given example is too strict, the requirement is to generate the
matched portion lazilly, and return the tail (unconsumed portion).
ah yes, without optimisations, Prelude.span builds up stack,
I don't quite understand why it does so at all.
span p [] = ([],[])
Hi all,
I was surprised to find out that the following piece of code:
length [1..] 10
isnt lazily evaluated! I wouldnt expect this to be a bug, but
in this case, shouldnt the computation end when the length function
evaluation goes something like:
10 + length [11..]
?
--
-- Vimal
Hi Vimal,
I was surprised to find out that the following piece of code:
length [1..] 10
isnt lazily evaluated!
The problem is that Int and Integer are both eager. It is possible to
write a lazy peano number based data type, but I'm not aware of anyone
who has - I have half the code (in
Vimal wrote:
Hi all,
I was surprised to find out that the following piece of code:
length [1..] 10
isnt lazily evaluated! I wouldnt expect this to be a bug, but
in this case, shouldnt the computation end when the length function
evaluation goes something like:
10 + length [11..]
I
Matthew Brecknell wrote:
Andrew Coppin:
Anybody happen to know what the time complexity of transpose is?
Bas van Dijk:
The worst case time complexity is O(r*c) where 'r' are the number of
rows and 'c' are the number of columns.
I believe Bas is correct, though it might be
Vimal wrote:
I was surprised to find out that the following piece of code:
length [1..] 10
isnt lazily evaluated! I wouldnt expect this to be a bug, but
in this case, shouldnt the computation end when the length function
evaluation goes something like:
10 + length [11..]
That's the
Vimal wrote:
Hi all,
I was surprised to find out that the following piece of code:
length [1..] 10
isnt lazily evaluated! I wouldnt expect this to be a bug, but
in this case, shouldnt the computation end when the length function
evaluation goes something like:
10 + length
On Mon, 24 Sep 2007, Vimal wrote:
Hi all,
I was surprised to find out that the following piece of code:
length [1..] 10
isnt lazily evaluated! I wouldnt expect this to be a bug, but
in this case, shouldnt the computation end when the length function
evaluation goes something like:
On Mon, 24 Sep 2007, Vimal wrote:
Hi all,
I was surprised to find out that the following piece of code:
length [1..] 10
isnt lazily evaluated!
http://www.haskell.org/haskellwiki/Things_to_avoid#Don.27t_ask_for_the_length_of_a_list_when_you_don.27t_need_it
Wow, half an hour, about 7 replies :) I dont know which one to quote!
Okay. So, why is GHC finding it difficult to conclude that
length is always 0? Suppose I define length like:
length [] = 0
length (x:xs) = 1 + length xs
Hmm, well, I think the fact that we, as humans, expecting GHC
to infer
On Mon, Sep 24, 2007 at 06:28:59PM +0200, apfelmus wrote:
I mean, Haskell does not magically detect that the 32(64)-bit integer
(10 + length [11..]) :: Int is bigger than 10 :: Int .
That's partly because it's not true.
There are arbitrarily large finite lists for which the equivalent is
From the wiki:
If you write it, you force Haskell to create all list nodes. ...
Alright.
Now, lets look at the definition again:
length [] = 0
length (x:xs) = 1 + length xs
We see that the value of *x* isnt needed at all. So, why does GHC
allocate so much memory creating all those *x*s?
Prelude 10 + length (replicate maxBound 'a')
-2147483639
Ah, nice example!
If you note, this doesnt allocate memory at all! Very less footprint!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
length [1..] 10
isnt lazily evaluated! I wouldnt expect this to be a bug, but
in this case, shouldnt the computation end when the length function
evaluation goes something like:
No. You want GHC to deduce that length would only increase in future.
This property is relatively complex and
Because transpose is quite lazy, it need not necessarily result in a
quadratic time complexity on every use.
On the other hand, my program needs the entire transposed list,
so... ;-)
May be, you should consider some other data structures, for example
(borrowed from fido7.ru.math):
data
Flooding haskell-cafe with extra traffic from haskel@ will lead to
comp.soft-sys.matlab syndrom where few people read anything but their own
postings and discussion is virtually unknown. I can see only two options
available to us right now to preserve readability in the fast growing Haskell
The gmane newsgroups corresponding to haskell mail lists can be found eg at:
http://gmane.org/find.php?list=haskell
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
* Rename haskell@ to haskell-announce@, and redirect mails from haskell@
to haskell-announce@ for some period.
(more, but can be done step by step in the future)
+1.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
On Mon, 2007-09-24 at 17:35 +0100, Andrew Coppin wrote:
Vimal wrote:
Hi all,
I was surprised to find out that the following piece of code:
length [1..] 10
isnt lazily evaluated! I wouldnt expect this to be a bug, but
in this case, shouldnt the computation end when the
Hi
In this world, use length (take 11 [1..]) 10...
not (null (drop 10 [1..])) is surely faster (not tested...)
Faster? There might be a few microseconds in it.
Clearer? Possibly... ;-)
lengthNat [1..] 10
Couldn't be clearer, and can be made to work perfectly. If anyone does
want to
Jonathan Cast wrote:
On Mon, 2007-09-24 at 17:35 +0100, Andrew Coppin wrote:
In an ideal world, yes.
In this world, use length (take 11 [1..]) 10...
not (null (drop 10 [1..])) is surely faster (not tested...)
Faster? There might be a few microseconds in it.
Clearer?
Hi and thanks for that many replies!
The haskell-cafe@ mailing list is more appropriate for messages such
as this. haskell@ is just for announcements (it should be called
haskell-annouce@ !)
Sorry for misposting.
I'd add:
* Discrete Maths - booleans, relations, functions etc.
* Type
Neil Mitchell wrote:
Hi
lengthNat [1..] 10
Couldn't be clearer, and can be made to work perfectly. If anyone does
want to pick up the lazy naturals work, I can send over the code (or
write it yourself - its not hard!)
Um... isn't a lazy natural just a list with no data, where the list
Hi
lengthNat [1..] 10
Couldn't be clearer, and can be made to work perfectly. If anyone does
want to pick up the lazy naturals work, I can send over the code (or
write it yourself - its not hard!)
Um... isn't a lazy natural just a list with no data, where the list
length encodes a
Neil Mitchell wrote:
Hi
Um... isn't a lazy natural just a list with no data, where the list
length encodes a number?
Pretty much, yes.
So I just need to write
newtype LazyNatural = LazyNatural [()]
and then add some suitable instances. ;-)
(Woah... that's one bizzare-looking
Hello,
I want to provide support for another OS. How are the POISIX modules
implemented? E.g. in terms of Green Card?
Kind regards, Bill Halchin
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Hi
Pretty much, yes.
So I just need to write
newtype LazyNatural = LazyNatural [()]
or
data Nat = Zero | Succ Nat
it's your choice really.
and then add some suitable instances. ;-)
Yes. Lots of them. Lots of instances and lots of methods.
Hey, the length function would then just
Neil Mitchell wrote:
Hi
Pretty much, yes.
So I just need to write
newtype LazyNatural = LazyNatural [()]
or
data Nat = Zero | Succ Nat
it's your choice really.
I'm guessing there's going to be fairly minimal performance difference.
(Or maybe there is. My way uses
If you read the memo1 function carefully you'll notice that the cache
always contains just one pair. It's coincident that just memo-ing one
last function application is enough for the SOE examples. You could,
for example, make it memo-ing last two or more results.
The reason for this memoization
Hi
I'm guessing there's going to be fairly minimal performance difference.
(Or maybe there is. My way uses a few additional pointers. But it also
allows me to elegantly recycle existing Prelude list functions, so...)
I think we can safely assume that people using peano numbers aren't
actually
On Mon, 24 Sep 2007, Vimal wrote:
Wow, half an hour, about 7 replies :) I dont know which one to quote!
Okay. So, why is GHC finding it difficult to conclude that
length is always 0? Suppose I define length like:
length [] = 0
length (x:xs) = 1 + length xs
Hmm, well, I think the fact
On Mon, Sep 24, 2007 at 04:10:30PM -0500, Galchin Vasili wrote:
I want to provide support for another OS. How are the POISIX modules
implemented? E.g. in terms of Green Card?
They use hsc2hs, the FFI and a splash of C.
You can get the sources from this darcs repo:
On 2007-09-24, Andrew Coppin [EMAIL PROTECTED] wrote:
Neil Mitchell wrote:
Hi
lengthNat [1..] 10
Couldn't be clearer, and can be made to work perfectly. If anyone does
want to pick up the lazy naturals work, I can send over the code (or
write it yourself - its not hard!)
Um... isn't
Since natural numbers are trivial to implement (inefficiently) I took 15
minutes and added them to my numbers package in Hackage.
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/numbers-2007.9.24
-- Lennart
On 9/24/07, Andrew Coppin [EMAIL PROTECTED] wrote:
Neil Mitchell wrote:
PS.
Prelude Data.List Data.Number.Natural genericLength [1..] (10 :: Natural)
True
On 9/24/07, Lennart Augustsson [EMAIL PROTECTED] wrote:
Since natural numbers are trivial to implement (inefficiently) I took 15
minutes and added them to my numbers package in Hackage.
nope.
it is true that in the case of an infinite list it exibits the desired
behaviour but ...
return (replicate 100 'a') = \x-print $ spant (const True) x
ERROR - Garbage collection fails to reclaim sufficient space
i.e. as the function unfold, the thunk representing the second term
Thanks, Ian.
Bill
On 9/24/07, Ian Lynagh [EMAIL PROTECTED] wrote:
On Mon, Sep 24, 2007 at 04:10:30PM -0500, Galchin Vasili wrote:
I want to provide support for another OS. How are the POISIX modules
implemented? E.g. in terms of Green Card?
They use hsc2hs, the FFI and a splash of
Dear haskell-cafe,
I would like to propose a new, ByteString like, Unicode string library
which can be used where both efficiency (currently offered by
ByteString) and i18n support (currently offered by vanilla Strings)
are needed. I wrote a skeleton draft today but I'm a bit tired so I
didn't
On 9/24/07, Henning Thielemann [EMAIL PROTECTED] wrote:
Unfortunately, properFraction doesn't work well with negative numbers.
This old chestnut! It's a common problem in practice. As I recall, the
behaviour of C's % operator allows implementations to yield either
behaviour. I just checked ISO
Johan Tibell wrote:
Dear haskell-cafe,
I would like to propose a new, ByteString like, Unicode string library
which can be used where both efficiency (currently offered by
ByteString) and i18n support (currently offered by vanilla Strings)
are needed. I wrote a skeleton draft today but I'm a
Claus Reinke wrote:
so everything that would be of interest to all haskellers,
including those too busy to follow haskell-cafe, would go to haskell,
everything else would go to haskell-cafe.
but even those topics starting out on haskell are meant
to migrate to haskell-cafe after a few posts at
return (replicate 100 'a') = \x-print $ spant (const True) x
ERROR - Garbage collection fails to reclaim sufficient space
i.e. as the function unfold, the thunk representing the second term builds
up on the heap.
true. i've often wanted a copy pseudo-function that would
avoid updating
Hi Peter. Paul Liu replied well to your later email, but I just wanted
to point out that memoization is not being used here to make the
recursion work -- lazy evaluation does just fine. Rather, the
memoization is being used for what it's normally good for, namely, to
avoid repeated
Now you've triggered an addict attack. Remember how Haskell is a gateway
drug?
Composition (.) may not be an abstract function, but it is very
fundamental one (so be wary of redefining the (.) operator in Haskell!).
Only the identity function id is more fundamental. [And actually, these
are
Of course I should have proofread this one more time!
What is a point? A point in Hask* is a type with only a single value in
it, from which all other values can be constructed. Every value x maps
trivially into a function (const x), and when you apply this function to
the (only) value of a
On Mon, Sep 24, 2007 at 06:47:05PM -0700, Dan Weston wrote:
Of course I should have proofread this one more time!
What is a point? A point in Hask* is a type with only a single value in
it, from which all other values can be constructed. Every value x maps
trivially into a function (const
Well, I did footnote in my first e-mail that:
[1] I used the asterisk in the category name Hask* to exclude undefined
values or partial functions
[Although I think I may have flipped the asterisk convention.]
I see what you mean by const False and const True being two different
arrows, but
Oh, duh! The only systematically distinguishable value in every type is
undefined, but I went and excluded that value from my fake Hask* class.
Never mind, I'll stop while I'm behind! :(
Dan Weston wrote:
Well, I did footnote in my first e-mail that:
[1] I used the asterisk in the category
On 25 Sep 2007, at 10:55 am, Thomas Conway wrote:
This old chestnut! It's a common problem in practice. As I recall, the
behaviour of C's % operator allows implementations to yield either
behaviour. I just checked ISO 9899:1999 which defines fmod. It
specifies that the result of fmod(x,y)
2007/9/22, Hugo Pacheco [EMAIL PROTECTED]:
Hi all,
If I want to write some function that will dynamically create a selection
function according to its arguments and do something with it.
You cannot dynamically create function, all you can is to create it at
compile-time (that's what TH lets
On Mon, 2007-09-24 at 19:11 -0700, Dan Weston wrote:
Well, I did footnote in my first e-mail that:
[1] I used the asterisk in the category name Hask* to exclude undefined
values or partial functions
[Although I think I may have flipped the asterisk convention.]
I see what you mean by
76 matches
Mail list logo