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: Cabal-install of local package (Stefan H?ck)
2. Haskell typing question (Cui Liqiang)
----------------------------------------------------------------------
Message: 1
Date: Tue, 28 Oct 2014 06:22:03 +0100
From: Stefan H?ck <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Cabal-install of local package
Message-ID: <20141028052203.GB11296@hunter>
Content-Type: text/plain; charset=iso-8859-1
So, I think I figured this out myself after some more googling:
`cabal sandbox add-source /path/to/efa-prelude`
did the trick as explained here:
http://coldwa.st/e/blog/2013-08-20-Cabal-sandbox.html
Please excuse the noise. Move on.
On Tue, Oct 28, 2014 at 05:49:21AM +0100, Stefan H?ck wrote:
> Dear list
>
> Like many other I seem to be struggling with some of the concepts of
> cabal and cabal-install. For the records: I use cabal-install 1.20.0.3
> and ghc 7.8.3 on arch linux.
>
> For starters, I implemented my own idea of an improved prelude, called
> the package efa-prelude and the module it exports Efa.Prelude. I then
> built the package and installed it using `cabal install --user`.
> This worked and a folder for the library was created at
> "$HOME/.cabal/lib/x86_64-linux-ghc-7.8.3/efa-prelude-0.1.0".
> I also registered the library using `cabal register --user` and
> now cabal prints some information about the package when I type
> `cabal info efa-prelude`. I am also able to import Efa.Prelude into
> ghci.
>
> However, when I now try to use this library in another local project
> using a sandbox this time, I can build the project but
> when I try to install it into the sandbox I get the following error
> message:
>
> Resolving dependencies...
> cabal: Could not resolve dependencies:
> trying: test-0.1.0 (user goal)
> next goal: efa-prelude (dependency of test-0.1.0)
> Dependency tree exhaustively searched.
>
> I just tried and the install works if I do it outside of a sandbox.
> Obviously I am missing something crucial here. Could somebody please point me
> in the right direction what is needed to make my own packages available
> in a sanboxed install?
>
> Thanks for your time
>
> Stefan
>
------------------------------
Message: 2
Date: Tue, 28 Oct 2014 20:00:29 +0800
From: Cui Liqiang <[email protected]>
To: [email protected], [email protected]
Subject: [Haskell-beginners] Haskell typing question
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
Thanks for your help, your suggestion works.
But I still don?t quite understand. In the following line:
caluDecimal l = (foldr1 (\x acc -> acc / 10.0 + x) (map digitToInt l)),
After applying digitToInt, the type of ?x? in the expression above is Int
indeed, but Haskell consider the ?10.0? to be a Int, is it?
----------------------------------------------------------------------------------------------------------------------------
Hi,
I am doing an exercise in Haskell, which is converting a string like ?$123.312?
to double value. Below is my code:
module Main where
import Data.Char
caluInt l = foldl1 (\acc x -> acc * 10 + x) (map digitToInt l)
caluDecimal l = (foldr1 (\x acc -> acc / 10.0 + x) (map digitToInt l))
convert(x:xs) =
let num = [e | e <- xs, e /= ',']
intPart = takeWhile (/='.') num
decimalPart = tail(dropWhile (/='.') num)
in (caluInt intPart) + (caluDecimal decimalPart)
And I got an error in this line: caluDecimal l = (foldr1 (\x acc -> acc / 10.0
+ x) (map digitToInt l)),
which says:
No instance for (Fractional Int) arising from a use of `/'
Possible fix: add an instance declaration for (Fractional Int)
In the first argument of `(+)', namely `acc / 10.0'
In the expression: acc / 10.0 + x
In the first argument of `foldr1', namely
`(\ x acc -> acc / 10.0 + x)'
Why Haskell insists that 10.0 is a Int? How can I explicitly tell Haskell I
want a Fractional?
--
Cui Liqiang
> Why Haskell insists that 10.0 is a Int? How can I explicitly tell Haskell
> I want a Fractional?
Because digitToInt means exactly what it says. If you want it to become
something other than Int, apply fromIntegral to its result.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20141028/6a31fd25/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 76, Issue 27
*****************************************