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. can somebody explain the type of this expression? (Ovidiu Deac)
2. Re: can somebody explain the type of this expression?
(Brandon Allbery)
3. Re: can somebody explain the type of this expression?
(Mike Meyer)
4. Re: can somebody explain the type of this expression?
(Ovidiu Deac)
5. error compiling haskell-src-1.0.1.4 (Jason T. Slack-Moehrle)
6. Cabal-install of local package (Stefan H?ck)
----------------------------------------------------------------------
Message: 1
Date: Mon, 27 Oct 2014 22:47:19 +0200
From: Ovidiu Deac <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] can somebody explain the type of this
expression?
Message-ID:
<cakvse7uqehoxttqk7wdm3v7vzvgectxt9k8mnm9wnmmiaph...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Prelude> let f x = x * 2
Prelude> :t f
f :: Num a => a -> a
The typeclass Num is defined like this:
class Num a where
(+), (-), (*) :: a -> a -> a
...
...which means that the operator (*) expects two parameters of type a and
returns a value of type a.
Since the definition of expr looks like this:
Prelude> let f x = x * 2
...and 2 is an Int, I would expect that the type inferred for (*) is (Int
-> Int -> Int) and thus f should be (Int -> Int)
Can somebody explain this?
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20141027/49372532/attachment-0001.html>
------------------------------
Message: 2
Date: Mon, 27 Oct 2014 16:54:20 -0400
From: Brandon Allbery <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] can somebody explain the type of this
expression?
Message-ID:
<cakfcl4wr+xuzptxntu_jaysf4exu8dydtlq6kgbipq8kdbz...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Mon, Oct 27, 2014 at 4:47 PM, Ovidiu Deac <[email protected]> wrote:
> Since the definition of expr looks like this:
> Prelude> let f x = x * 2
>
> ...and 2 is an Int, I would expect that the type inferred for (*) is (Int
> -> Int -> Int) and thus f should be (Int -> Int)
>
Prelude> :t 2
2 :: Num a => a
Numeric literals are polymorphic.
http://www.haskell.org/onlinereport/haskell2010/haskellch6.html#x13-1360006.4.1
is the official specification of this.
--
brandon s allbery kf8nh sine nomine associates
[email protected] [email protected]
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20141027/554ebcb3/attachment-0001.html>
------------------------------
Message: 3
Date: Mon, 27 Oct 2014 15:54:07 -0500
From: Mike Meyer <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] can somebody explain the type of this
expression?
Message-ID:
<CAD=7u2bzgag3t8+xceck3pt4gbf88xemcteb1v_nwxdntko...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Mon, Oct 27, 2014 at 3:47 PM, Ovidiu Deac <[email protected]> wrote:
> Prelude> let f x = x * 2
> Prelude> :t f
> f :: Num a => a -> a
>
> The typeclass Num is defined like this:
>
> class Num a where
> (+), (-), (*) :: a -> a -> a
> ...
>
> ...which means that the operator (*) expects two parameters of type a and
> returns a value of type a.
>
> Since the definition of expr looks like this:
> Prelude> let f x = x * 2
>
> ...and 2 is an Int, I would expect that the type inferred for (*) is (Int
> -> Int -> Int) and thus f should be (Int -> Int)
>
> Can somebody explain this?
>
> Thanks!
>
Not sure of the terminology, but 2 can be coerced to any different type of
Num, so that it can be used in non-Int expressions:
2 / 3
0.6666666666666666
Prelude> :t 2 / 3
2 / 3 :: Fractional a => a
Prelude> :t 2
2 :: Num a => a
Note that Fractional is also a type class, not a type like Int, so Floating
types do the same thing. For that mater, if you enabled OverloadedStrings,
you can get that behavior out of strings:
Prelude> :t "abc"
"abc" :: [Char]
Prelude> :set -XOverloadedStrings
Prelude> :t "abc"
"abc" :: Data.String.IsString a => a
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20141027/e6d02205/attachment-0001.html>
------------------------------
Message: 4
Date: Mon, 27 Oct 2014 23:02:02 +0200
From: Ovidiu Deac <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>,
Brandon Allbery <[email protected]>
Subject: Re: [Haskell-beginners] can somebody explain the type of this
expression?
Message-ID:
<cakvse7st92glfa1foec4ghnfmvzc3u6+82td-wfb5lgkpg3...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Makes sense. Thanks!
On Mon, Oct 27, 2014 at 10:54 PM, Brandon Allbery <[email protected]>
wrote:
> On Mon, Oct 27, 2014 at 4:47 PM, Ovidiu Deac <[email protected]> wrote:
>
>> Since the definition of expr looks like this:
>> Prelude> let f x = x * 2
>>
>> ...and 2 is an Int, I would expect that the type inferred for (*) is
>> (Int -> Int -> Int) and thus f should be (Int -> Int)
>>
>
> Prelude> :t 2
> 2 :: Num a => a
>
> Numeric literals are polymorphic.
> http://www.haskell.org/onlinereport/haskell2010/haskellch6.html#x13-1360006.4.1
> is the official specification of this.
>
> --
> brandon s allbery kf8nh sine nomine
> associates
> [email protected]
> [email protected]
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20141027/af6d2fac/attachment-0001.html>
------------------------------
Message: 5
Date: Mon, 27 Oct 2014 20:11:12 -0700
From: "Jason T. Slack-Moehrle" <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] error compiling haskell-src-1.0.1.4
Message-ID:
<caeyvkjm6ukuvdzmomlnz4suqb77-mxtazsubvqd_mxjkfh_...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
I am trying to compile haskell-platform on an AWS instance. The version:
haskell-platform-2011.2.0.0
It was going OK, but now I am getting an error I dont know how to solve:
Building haskell-src-1.0.1.4...
[1 of 6] Compiling Language.Haskell.Syntax ( Language/Haskell/Syntax.hs,
dist/build/Language/Haskell/Syntax.o )
[2 of 6] Compiling Language.Haskell.Pretty ( Language/Haskell/Pretty.hs,
dist/build/Language/Haskell/Pretty.o )
[3 of 6] Compiling Language.Haskell.ParseMonad (
Language/Haskell/ParseMonad.hs, dist/build/Language/Haskell/ParseMonad.o )
[4 of 6] Compiling Language.Haskell.ParseUtils (
Language/Haskell/ParseUtils.hs, dist/build/Language/Haskell/ParseUtils.o )
[5 of 6] Compiling Language.Haskell.Lexer ( Language/Haskell/Lexer.hs,
dist/build/Language/Haskell/Lexer.o )
[6 of 6] Compiling Language.Haskell.Parser (
dist/build/Language/Haskell/Parser.hs, dist/build/Language/Haskell/Parser.o
)
dist/build/Language/Haskell/Parser.hs:0:36:
The function `runParserWithMode' is applied to 8 arguments,
but its type `ParseMode -> P a0 -> String -> ParseResult a0'
has only three
In the expression: runParserWithMode mode parse 1 3 4 3 4 2
In an equation for `parseModuleWithMode':
parseModuleWithMode mode = runParserWithMode mode parse 1 3 4 3 4 2
Error:
Building the haskell-src-1.0.1.4 package failed
make: *** [build.stamp] Error 2
Can anyone help me get past this?
Best,
Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20141027/e885913b/attachment-0001.html>
------------------------------
Message: 6
Date: Tue, 28 Oct 2014 05:49:21 +0100
From: Stefan H?ck <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Cabal-install of local package
Message-ID: <20141028044921.GA11296@hunter>
Content-Type: text/plain; charset=us-ascii
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
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 76, Issue 26
*****************************************