Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: homogeneous value list (Ron Leisti)
2. Re: homogeneous value list (Daniel Fischer)
3. Re: homogeneous value list (Heinrich Apfelmus)
4. Primes calculation (legajid)
5. Re: Primes calculation (Daniel Fischer)
6. Issues Installing haskelldb-hsql-sqlite3 (aditya siram)
7. Re: Issues Installing haskelldb-hsql-sqlite3 (Daniel Fischer)
8. Issues With Install Script in Haskell Platform 2009.2.0.2
(aditya siram)
9. [SOLVED] Issues With Install Script in Haskell Platform
2009.2.0.2 (aditya siram)
----------------------------------------------------------------------
Message: 1
Date: Fri, 12 Mar 2010 09:44:18 -0500
From: Ron Leisti <[email protected]>
Subject: Re: [Haskell-beginners] homogeneous value list
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Does this have any implications say, for using infinite data
structures? When we can we assume laziness (in order to use
abstractions like infinity), and when can we not?
On Fri, Mar 12, 2010 at 9:39 AM, Thomas Davie <[email protected]> wrote:
>
> On 12 Mar 2010, at 14:33, Ozgur Akgun wrote:
>
>
> On 12 March 2010 14:28, Thomas Davie <[email protected]> wrote:
>>
>> On 12 Mar 2010, at 14:25, Salil Wadnerkar wrote:
>>
>> On Fri, Mar 12, 2010 at 10:21 PM, Ozgur Akgun <[email protected]>
>> wrote:
>>
>> Another boring variant from me then.
>>
>> isHomogeneous xs = all (first==) xs
>>
>> where first = head xs
>>
>>
>> Shouldn't
>> head xs
>> give an exception on an empty list?
>>
>> An error, and only if it's evaluated. Lazy evaluation means it's not
>> evaluated here.
>> Of course another non-strict algorithm *might* evaluate head xs here, so
>> this version won't work in all possible Haskell implementations, only the
>> current ones which use lazy evaluation.
>> Bob
>
> So we need to make sure our code would work in a strict environment, even
> though we are using a lazily evaluated language, just in case if someone
> comes up with a not-that-lazy implementation of haskell?
>
> If I was thinking this way, I would just stop using haskell at all.
>
> Not quite, you need to make sure your code works in *all* non-strict
> evaluation models. Lazy evaluation is not the only non-strict evaluation
> method, another implementation of non-strict semantics might actually
> evaluate head xs.
> Bob
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
------------------------------
Message: 2
Date: Fri, 12 Mar 2010 17:15:24 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] homogeneous value list
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Am Freitag 12 März 2010 15:40:36 schrieb Brent Yorgey:
> On Fri, Mar 12, 2010 at 03:31:54PM +0100, Daniel Fischer wrote:
> > Am Freitag 12 März 2010 15:25:48 schrieb Salil Wadnerkar:
> > > On Fri, Mar 12, 2010 at 10:21 PM, Ozgur Akgun <[email protected]>
> >
> > wrote:
> > > > Another boring variant from me then.
> > > >
> > > > isHomogeneous xs = all (first==) xs
> > > > where first = head xs
> > >
> > > Shouldn't
> > > head xs
> > > give an exception on an empty list?
> >
> > Only if it's demanded, which it isn't here, since all doesn't look at
> > the condition when facing an empty list.
> >
> > But it's good practice to never call head on a list which may be
> > empty, so I wouldn't like Ozgur's variant in real code. It's great for
> > golf, though
> >
> > :D
>
> I would argue that it's good practice simply to never call head at
> all. I stopped a while ago, and I haven't missed it. =)
>
> -Brent
I would argue that in
snub = map head . group . sort
and the like, calling head is perfectly cromulent. But apart from that, I
don't remember using head in the last years.
------------------------------
Message: 3
Date: Fri, 12 Mar 2010 18:00:10 +0100
From: Heinrich Apfelmus <[email protected]>
Subject: [Haskell-beginners] Re: homogeneous value list
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
Thomas Davie wrote:
> Salil Wadnerkar wrote:
>> Ozgur Akgun wrote:
>>
>>> Another boring variant from me then.
>>>
>>> isHomogeneous xs = all (first==) xs
>>> where first = head xs
>>
>> Shouldn't
>> head xs
>> give an exception on an empty list?
>
> An error, and only if it's evaluated. Lazy evaluation means it's not
> evaluated here.
>
> Of course another non-strict algorithm *might* evaluate head xs here,
> so this version won't work in all possible Haskell implementations,
> only the current ones which use lazy evaluation.
Nope, this works for any non-strict implementation. It can be deduced
from the Haskell98 language standard that all has the property
all ⥠[] = True
(Non-strict semantics doesn't tell you anything about time and space
behavior, though; that's where you need the information that the
compiler is using lazy evaluation.)
Regards,
Heinrich Apfelmus
--
http://apfelmus.nfshost.com
------------------------------
Message: 4
Date: Fri, 12 Mar 2010 22:14:00 +0100
From: legajid <[email protected]>
Subject: [Haskell-beginners] Primes calculation
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hi,
i'm trying to write a function to find all primes from 2 to N.
My idea is :
take the first number (2)
try to find whether it's a multiple of one of all existing primes
([] at first)
add 2 to the list of primes
take the following number (3)
find if multiple of existing primes ([2])
add 3 to the list of primes
take the following number (4)
find if multiple of existing primes ([2, 3])
do not add 4 to the list of primes
...
take the following number (8)
find if multiple of existing primes ([2, 3, 5, 7])
do not add 8 to the list of primes
take the following number (9)
find if multiple of existing primes ([2, 3, 5, 7])
do not add 9 to the list of primes (multiple of 3)
and so on...
So, i would like a function like :
f (x : xs) = g x : f xs
g would return x if x is prime, [] otherwise
But g would use the preceding value of f (list of primes before the
calculation for x) that is a result of g itself.
f needs g that needs f : what's wrong with my mind ?
Perhaps i am still under control of imperative programming ?
Thanks for your help,
Didier.
------------------------------
Message: 5
Date: Fri, 12 Mar 2010 22:28:31 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Primes calculation
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Am Freitag 12 März 2010 22:14:00 schrieb legajid:
> Hi,
> i'm trying to write a function to find all primes from 2 to N.
>
Many examples at http://www.haskell.org/haskellwiki/Prime_numbers
>
> My idea is :
> take the first number (2)
> try to find whether it's a multiple of one of all existing primes
> ([] at first)
> add 2 to the list of primes
>
> take the following number (3)
> find if multiple of existing primes ([2])
> add 3 to the list of primes
>
> take the following number (4)
> find if multiple of existing primes ([2, 3])
> do not add 4 to the list of primes
>
> ...
>
> take the following number (8)
> find if multiple of existing primes ([2, 3, 5, 7])
> do not add 8 to the list of primes
>
> take the following number (9)
> find if multiple of existing primes ([2, 3, 5, 7])
> do not add 9 to the list of primes (multiple of 3)
>
> and so on...
>
> So, i would like a function like :
>
> f (x : xs) = g x : f xs
>
> g would return x if x is prime, [] otherwise
>
> But g would use the preceding value of f (list of primes before the
> calculation for x) that is a result of g itself.
So g would need the list of primes [found so far] as a parameter (without
that, it would need to check whether x is prime from scratch).
If you're not committed to performance, what about simple trial division:
trialDivPrime :: [Integer] -> Integer -> Bool
trialDivPrime (p:ps) n
= (n < p*p) || (n `mod` p /= 0 && trialDivPrime ps n)
isPrime = trialDivPrime primes
primes = 2:filter isPrime [3, 5 .. ]
If you're after performance, a bit-sieve (STUArray) is what you want.
> f needs g that needs f : what's wrong with my mind ?
> Perhaps i am still under control of imperative programming ?
>
> Thanks for your help,
>
> Didier.
------------------------------
Message: 6
Date: Fri, 12 Mar 2010 15:55:15 -0600
From: aditya siram <[email protected]>
Subject: [Haskell-beginners] Issues Installing haskelldb-hsql-sqlite3
To: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Hi all,
I am having an issue installing haskelldb-hsql-sqlite3.
When I do a 'cabal-install install haskelldb-hsql-sqlite3', it tries
to rebuild 'directory-1.0.0.3' even though it is available and gives
the following error:
Building directory-1.0.0.3...
System/Directory.hs:81:7:
Could not find module `Control.Exception.Base':
it is a member of the hidden package `base'
Use -v to see a list of the files searched for.
Any feedback is appreciated.
-deech
------------------------------
Message: 7
Date: Fri, 12 Mar 2010 23:33:15 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Issues Installing
haskelldb-hsql-sqlite3
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Am Freitag 12 März 2010 22:55:15 schrieb aditya siram:
> Hi all,
> I am having an issue installing haskelldb-hsql-sqlite3.
>
> When I do a 'cabal-install install haskelldb-hsql-sqlite3', it tries
> to rebuild 'directory-1.0.0.3' even though it is available and gives
> the following error:
> Building directory-1.0.0.3...
>
> System/Directory.hs:81:7:
> Could not find module `Control.Exception.Base':
> it is a member of the hidden package `base'
> Use -v to see a list of the files searched for.
Odd. base is listed as a dependency for directory-1.0.0.3. And if you
already have directory-1.0.0.3, it shouldn't be rebuilt - except if it's in
your user package-db and you're trying to make a global install of
haskelldb-hsql-sqlite3.
Which GHC version are you running, and on which OS? (That might or might
not be relevant.)
First, run "ghc-pkg check" to see whether some of your installed packages
are broken. If none are, try "cabal install -v haskelldb-hsql-sqlite3",
perhaps a verbose run would make it clearer what went wrong - or, try
installing directory-1.0.1.0 and then haskelldb*
>
> Any feedback is appreciated.
> -deech
------------------------------
Message: 8
Date: Fri, 12 Mar 2010 18:22:29 -0600
From: aditya siram <[email protected]>
Subject: [Haskell-beginners] Issues With Install Script in Haskell
Platform 2009.2.0.2
To: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Hi all,
I am running Ubuntu Karmic Kameleon and GHC 6.10.4 and am having
issues with the Haskell Platform 2009.2.0.2 source installer.
The 'configure' and 'make' step work fine, but 'make install' errors with:
scripts/install.sh
Installing mtl-1.1.0.2...
Error:
The mtl-1.1.0.2/Setup script does not exist or cannot be run
And indeed mtl-1.1.0.2/Setup does not exist. It appears that the
'make' step builds some packages and not others. The 'Setup'
executable is only in the following package directories:
./network-2.2.1.4/Setup
./editline-0.2.1.0/Setup
./alex-2.3.1/Setup
./happy-1.18.4/Setup
./haskell-platform-2009.2.0.2/Setup
./fgl-5.4.2.2/Setup
./cgi-3001.1.7.1/Setup
./cabal-install-0.6.2/Setup
./HTTP-4000.0.6/Setup
./GLUT-2.1.1.2/Setup
./OpenGL-2.2.1.1/Setup
./zlib-0.5.0.0/Setup
./time-1.1.2.4/Setup
Here is the current contents of my global and local packages:
Global Packages:
Cabal-1.6.0.3, HUnit-1.2.0.3, QuickCheck-1.2.0.0, array-0.2.0.0,
base-3.0.3.1, base-4.1.0.0, bytestring-0.9.1.4, containers-0.2.0.1,
directory-1.0.0.3, (dph-base-0.3), (dph-par-0.3),
(dph-prim-interface-0.3), (dph-prim-par-0.3), (dph-prim-seq-0.3),
(dph-seq-0.3), extensible-exceptions-0.1.1.0, filepath-1.1.0.2,
(ghc-6.10.4), ghc-prim-0.1.0.0, haddock-2.4.2, haskell-src-1.0.1.3,
haskell98-1.0.1.0, hpc-0.5.0.3, html-1.0.1.2, integer-0.1.0.1,
mtl-1.1.0.2, network-2.2.1.2, old-locale-1.0.0.1, old-time-1.0.0.2,
packedstring-0.1.0.1, parallel-1.1.0.1, parsec-2.1.0.1,
pretty-1.0.1.0, process-1.0.1.1, random-1.0.0.1,
regex-base-0.72.0.2, regex-compat-0.71.0.1, regex-posix-0.72.0.3,
rts-1.0, stm-2.1.1.2, syb-0.1.0.1, template-haskell-2.3.0.1,
time-1.1.4, unix-2.3.2.0, xhtml-3000.2.0.1
Local Packages:
haskelldb-0.13, haskelldb-hsql-0.10, haskelldb-hsql-sqlite3-0.10,
hsql-1.8.1, hsql-sqlite3-1.8.1
------------------------------
Message: 9
Date: Fri, 12 Mar 2010 18:26:08 -0600
From: aditya siram <[email protected]>
Subject: [Haskell-beginners] [SOLVED] Issues With Install Script in
Haskell Platform 2009.2.0.2
To: beginners <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
It looks as though the Haskell platform install script doesn't like it
if you are overwriting an existing installation.
The problem is line 18 of scripts/install.sh:
[ -x Setup ] || die "The ${PKG}/Setup script does not exist or cannot be run"
So if the 'Setup' executable doesn't exist in a certain directory the
whole process errors. For my purposes I changed it to:
[ -x Setup ] || return 0
and things proceeded smoothly.
Thanks!
-deech
On 3/12/10, aditya siram <[email protected]> wrote:
> Hi all,
> I am running Ubuntu Karmic Kameleon and GHC 6.10.4 and am having
> issues with the Haskell Platform 2009.2.0.2 source installer.
>
> The 'configure' and 'make' step work fine, but 'make install' errors with:
> scripts/install.sh
> Installing mtl-1.1.0.2...
> Error:
> The mtl-1.1.0.2/Setup script does not exist or cannot be run
>
> And indeed mtl-1.1.0.2/Setup does not exist. It appears that the
> 'make' step builds some packages and not others. The 'Setup'
> executable is only in the following package directories:
> ./network-2.2.1.4/Setup
> ./editline-0.2.1.0/Setup
> ./alex-2.3.1/Setup
> ./happy-1.18.4/Setup
> ./haskell-platform-2009.2.0.2/Setup
> ./fgl-5.4.2.2/Setup
> ./cgi-3001.1.7.1/Setup
> ./cabal-install-0.6.2/Setup
> ./HTTP-4000.0.6/Setup
> ./GLUT-2.1.1.2/Setup
> ./OpenGL-2.2.1.1/Setup
> ./zlib-0.5.0.0/Setup
> ./time-1.1.2.4/Setup
>
> Here is the current contents of my global and local packages:
> Global Packages:
> Cabal-1.6.0.3, HUnit-1.2.0.3, QuickCheck-1.2.0.0, array-0.2.0.0,
> base-3.0.3.1, base-4.1.0.0, bytestring-0.9.1.4, containers-0.2.0.1,
> directory-1.0.0.3, (dph-base-0.3), (dph-par-0.3),
> (dph-prim-interface-0.3), (dph-prim-par-0.3), (dph-prim-seq-0.3),
> (dph-seq-0.3), extensible-exceptions-0.1.1.0, filepath-1.1.0.2,
> (ghc-6.10.4), ghc-prim-0.1.0.0, haddock-2.4.2, haskell-src-1.0.1.3,
> haskell98-1.0.1.0, hpc-0.5.0.3, html-1.0.1.2, integer-0.1.0.1,
> mtl-1.1.0.2, network-2.2.1.2, old-locale-1.0.0.1, old-time-1.0.0.2,
> packedstring-0.1.0.1, parallel-1.1.0.1, parsec-2.1.0.1,
> pretty-1.0.1.0, process-1.0.1.1, random-1.0.0.1,
> regex-base-0.72.0.2, regex-compat-0.71.0.1, regex-posix-0.72.0.3,
> rts-1.0, stm-2.1.1.2, syb-0.1.0.1, template-haskell-2.3.0.1,
> time-1.1.4, unix-2.3.2.0, xhtml-3000.2.0.1
> Local Packages:
> haskelldb-0.13, haskelldb-hsql-0.10, haskelldb-hsql-sqlite3-0.10,
> hsql-1.8.1, hsql-sqlite3-1.8.1
>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 21, Issue 12
*****************************************