Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/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: Problem with installing GHCi 8.0.1 (Russ Abbott)
2. Problem with numeric types (Russ Abbott)
3. Re: Problem with numeric types (David McBride)
----------------------------------------------------------------------
Message: 1
Date: Fri, 01 Jul 2016 15:52:25 +0000
From: Russ Abbott <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Problem with installing GHCi 8.0.1
Message-ID:
<cagkqki6mc+zqi8mmbdpnmral+sg3hxzg+opvd7fgi8msggf...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Sorry to be so dense, but how do you run the portable install option. After
downloading the "Minimal platform I have a .exe installer file. When I run
it, it doesn't offer a portable install option. What am I doing wrong?
Thanks.
On Fri, Jul 1, 2016 at 4:26 AM Henk-Jan van Tuyl <[email protected]> wrote:
> On Fri, 01 Jul 2016 06:17:22 +0200, Russ Abbott <[email protected]>
> wrote:
>
> > I downloaded GHCi 8.0.1 for Windows. Since I don't have administrator
> > privileges I repeatedly clicked no when asked if I wanted to stop and
> > restart with elevated privileges. Eventually it installed (in a folder on
> > the desktop). The next step tells me to change some lines in the cabal
> > user-config file. I followed the instructions to find that file, but
> > all I
> > got was an html file, which didn't seem right. I looked manually in
> > multiple directories, but nothing seemed like the right file. Would
> > someone help me find the file that needs to be changed.
>
> Searching for
> cabal config windows
> lead me to
>
> https://wiki.haskell.org/Cabal-Install#The_cabal-install_configuration_file
> which tells me that the config file is
> %appdata%\cabal\config
> That file should be created during installation, but you can create it
> yourself if necessary.
>
> > Also, WinGHCi does not appear in my start menu. Should it appear there by
> > this point?
>
> That is not done automatically; you can do it by right clicking on
> winghci.exe and selecting the proper option from the menu that appears.
>
> Regards,
> Henk-Jan van Tuyl
>
>
> --
> Folding@home
> What if you could share your unused computer power to help find a cure? In
> just 5 minutes you can join the world's biggest networked computer and get
> us closer sooner. Watch the video.
> http://folding.stanford.edu/
>
>
> http://Van.Tuyl.eu/
> http://members.chello.nl/hjgtuyl/tourdemonad.html
> Haskell programming
> --
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20160701/8e021250/attachment-0001.html>
------------------------------
Message: 2
Date: Sat, 02 Jul 2016 01:41:56 +0000
From: Russ Abbott <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Problem with numeric types
Message-ID:
<CAGkQki5pMrdEjThKwbfom-SjBcR2TxKpe_dovB=cgddlehm...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
I'm trying to define primes using just list comprehension. The following
works.
Prelude> odds = [3, 5..]
Prelude> primes = 2 : [p | p <- odds, null [d | d <- take (p `div` 4) odds,
p `mod` d == 0]]
But when I replace "take (p `div` 4)" with takeWhile (<=(sqrt p)) as
in
Prelude> primes' = 2 : [p | p <- odds, null [d | d <- (takeWhile (<=(sqrt
p)) odds), p `mod` d == 0]]
I get no error message on entering the statement, but when I run
Prelude> take 8 primes'
I get an error message that I can't understand.
<interactive>:23:1: error:
• Ambiguous type variable ‘a0’ arising from a use of ‘it’
prevents the constraint ‘(Floating a0)’ from being solved.
Probable fix: use a type annotation to specify what ‘a0’ should be.
These potential instances exist:
instance Floating Double -- Defined in ‘GHC.Float’
instance Floating Float -- Defined in ‘GHC.Float’
• In the first argument of ‘print’, namely ‘it’
In a stmt of an interactive GHCi command: print it
I tried using (ceiling (sqrt p)), and I tried to explicitly declare it an
Int, but neither of those helped.
I'd appreciate some help.
Thanks.
P.S. The following runs fine.
Prelude> takeWhile (<= (sqrt 99)) odds
So I'm completely stumped.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20160702/d97acbe1/attachment-0001.html>
------------------------------
Message: 3
Date: Sat, 2 Jul 2016 02:09:27 -0400
From: David McBride <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Problem with numeric types
Message-ID:
<can+tr43ugtigchmlm5f1+ouhs9nyqpckqw6ozw12k1--nea...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Because mod :: Integral a => a -> a -> a and sqrt :: Floating a => a -> a,
the final type of primes' ends up being :: (Floating a, Integral a) => [a],
which doesn't work very well obviously.
The easiest solution is to try
let primes' = 2 : [p | p <- odds, null [d | d <- (takeWhile (<=ceiling
(sqrt (fromInteger p))) odds), p `mod` d == 0]]
You can make your own sqrt if you want to clean it up.
let isqrt = ceiling . sqrt . fromInteger
On Fri, Jul 1, 2016 at 9:41 PM, Russ Abbott <[email protected]> wrote:
> I'm trying to define primes using just list comprehension. The following
> works.
>
> Prelude> odds = [3, 5..]
>
> Prelude> primes = 2 : [p | p <- odds, null [d | d <- take (p `div` 4)
> odds, p `mod` d == 0]]
>
>
> But when I replace "take (p `div` 4)" with takeWhile (<=(sqrt p))
> as in
>
> Prelude> primes' = 2 : [p | p <- odds, null [d | d <- (takeWhile (<=(sqrt
> p)) odds), p `mod` d == 0]]
>
> I get no error message on entering the statement, but when I run
>
> Prelude> take 8 primes'
>
> I get an error message that I can't understand.
>
> <interactive>:23:1: error:
> • Ambiguous type variable ‘a0’ arising from a use of ‘it’
> prevents the constraint ‘(Floating a0)’ from being solved.
> Probable fix: use a type annotation to specify what ‘a0’ should be.
> These potential instances exist:
> instance Floating Double -- Defined in ‘GHC.Float’
> instance Floating Float -- Defined in ‘GHC.Float’
> • In the first argument of ‘print’, namely ‘it’
> In a stmt of an interactive GHCi command: print it
>
> I tried using (ceiling (sqrt p)), and I tried to explicitly declare it an
> Int, but neither of those helped.
>
> I'd appreciate some help.
>
> Thanks.
>
> P.S. The following runs fine.
>
> Prelude> takeWhile (<= (sqrt 99)) odds
>
> So I'm completely stumped.
>
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20160702/68226c2e/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 97, Issue 2
****************************************