Mait | 16 Apr 23:50 2012
Picon

http://learnyouahaskell.com' tutorial)

ENV

Ubuntu 12.04
haskell-platform/precise uptodate 2012.1.0.0~debian

ghci --version
The Glorious Glasgow Haskell Compilation System, version 7.4.1

I've tried all day with,
'Learn You a Haskell for Great Good!'
http://learnyouahaskell.com/

Very attractive book. I'm really enjoying this book.

Anyway I have one question,

Why I can't declare func type like books?

I got always error about 'lacks an accompanying binding', like this,

Prelude> :l baby.hs
[1 of 1] Compiling Main             ( baby.hs, interpreted )

baby.hs:32:1:
     The type signature for take' lacks an accompanying binding
Failed, modules loaded: none.

Here is codepad link,
http://codepad.org/ttZRBpkL

(Continue reading)

Jakub Oboza | 16 Apr 23:55 2012
Picon

http://learnyouahaskell.com' tutorial)

Because GHC is limited

in GHC you cant do 

double a = a * a

you have to put into let
like this

let double a = a * a 

Cheers!

On 16 Apr 2012, at 22:50, Mait wrote:

> ENV
> 
> Ubuntu 12.04
> haskell-platform/precise uptodate 2012.1.0.0~debian
> 
> ghci --version
> The Glorious Glasgow Haskell Compilation System, version 7.4.1
> 
> I've tried all day with,
> 'Learn You a Haskell for Great Good!'
> http://learnyouahaskell.com/
> 
> Very attractive book. I'm really enjoying this book.
> 
> Anyway I have one question,
(Continue reading)

aditya siram | 17 Apr 00:29 2012
Picon

http://learnyouahaskell.com' tutorial)

It's not working because you don't have a definition for take'. If you
want to fill it in later you can just do:

take' = undefined

-deech

On Mon, Apr 16, 2012 at 4:55 PM, Jakub Oboza <jakub.oboza <at> gmail.com> wrote:
> Because GHC is limited
>
> in GHC you cant do
>
> double a = a * a
>
> you have to put into let
> like this
>
> let double a = a * a
>
> Cheers!
>
> On 16 Apr 2012, at 22:50, Mait wrote:
>
>> ENV
>>
>> Ubuntu 12.04
>> haskell-platform/precise uptodate 2012.1.0.0~debian
>>
>> ghci --version
>> The Glorious Glasgow Haskell Compilation System, version 7.4.1
(Continue reading)

Kyle Murphy | 17 Apr 00:39 2012
Picon

http://learnyouahaskell.com' tutorial)

As aditya pointed out, you need to declare any function you use (or provide a type signature of) but don't explicitly define as undefined. That will allow the code to compile but will throw an error when any undefined functions are called.

I want to address what Jakub said however as I think it's somewhat misleading.

On Mon, Apr 16, 2012 at 17:55, Jakub Oboza <jakub.oboza <at> gmail.com> wrote:
> Because GHC is limited
>
> in GHC you cant do
>
> double a = a * a
>
> you have to put into let
> like this
>
> let double a = a * a
>
> Cheers!

It might be more accurate to say that GHCi (the interactive shell, not GHC the compiler) makes some assumptions about what you're typing in order to make it more useful. For example, GHCi assumes that you're always typing something of the form:

IO a

This is why you need to change most "normal" haskell expressions into let bindings, because then you're explicitly telling GHCi that you don't want to interpret what you're typing as an IO expression. The reason it makes that assumption is because often times you really do want it interpreted as IO as in the example:

ghci> putStrLn $ "Example " ++ show 5
Example 5

It also makes assumptions about types of constants that GHC normally does not. Furthermore it allows rebinding of declarations as in:

ghci> let x = 5
ghci> x
5
ghci> let x = 6
ghci> x
6

You need to be careful with that though because something like this will not behave as you might expect:

ghci> let x = 5
ghci> let f = x * x
ghci> f
25
ghci> let x = 10
ghci> f
25

GHCi is very powerful and a great way to experiment and test code out, but it's important to understand some of the assumptions it makes in order to be more productive in the majority of cases. On Linux it's often best to start with an empty hs file, load that into GHCi, and then use :edit to open it in an editor and fill the contents out. You can then save and exit your editor and it will return you to the GHCi prompt where you can experiment and inspect the code you've written.

-R. Kyle Murphy
--
Curiosity was framed, Ignorance killed the cat.

<div><p>As aditya pointed out, you need to declare any function you use (or provide a type signature of) but don't explicitly define as undefined. That will allow the code to compile but will throw an error when any undefined functions are called.<br><br>I want to address what Jakub said however as I think it's somewhat misleading.<br><br>On Mon, Apr 16, 2012 at 17:55, Jakub Oboza <span dir="ltr">&lt;<a href="mailto:jakub.oboza <at> gmail.com">jakub.oboza <at> gmail.com</a>&gt;</span> wrote:<br>

&gt; Because GHC is limited<br>
&gt; 
<br>
&gt; 
in GHC you cant do<br>
&gt; 
<br>
&gt; 
double a = a * a<br>
&gt; 
<br>
&gt; 
you have to put into let<br>
&gt; 
like this<br>

&gt; <br>
&gt; 
let double a = a * a<br>

&gt; <br>
&gt; Cheers!<br><br>It might be more accurate to say that GHCi (the interactive shell, not GHC the compiler) makes some assumptions about what you're typing in order to make it more useful. For example, GHCi assumes that you're always typing something of the form:<br><br>IO a<br><br>This is why you need to change most "normal" haskell expressions into let bindings, because then you're explicitly telling GHCi that you don't want to interpret what you're typing as an IO expression. The reason it makes that assumption is because often times you really do want it interpreted as IO as in the example:<br><br>ghci&gt; putStrLn $ "Example " ++ show 5<br>Example 5<br><br>It also makes assumptions about types of constants that GHC normally does not. Furthermore it allows rebinding of declarations as in:<br><br>ghci&gt; let x = 5<br>
ghci&gt; x<br>5<br>ghci&gt; let x = 6<br>ghci&gt; x<br>6<br><br>You need to be careful with that though because something like this will not behave as you might expect:<br><br>ghci&gt; let x = 5<br>ghci&gt; let f = x * x<br>
ghci&gt; f<br>25<br>ghci&gt; let x = 10<br>ghci&gt; f<br>25<br><br>GHCi is very powerful and a great way to experiment and test code out, but it's important to understand some of the assumptions it makes in order to be more productive in the majority of cases. On Linux it's often best to start with an empty hs file, load that into GHCi, and then use :edit to open it in an editor and fill the contents out. You can then save and exit your editor and it will return you to the GHCi prompt where you can experiment and inspect the code you've written.<br clear="all"><br>-R. Kyle Murphy<br>--<br>Curiosity was framed, Ignorance killed the cat.<br></p></div>
Jack Henahan | 17 Apr 04:56 2012
Picon

http://learnyouahaskell.com' tutorial)

Additionally, "take' :: (Ord b, bum b) => b -> [a] -> [a]" should be "take' :: (Ord b, Num b) => b -> [a] -> [a]"

Jack Henahan
jhenahan <at> uvm.edu
==
Computer science is no more about computers than astronomy is about telescopes.
-- Michael R. Fellows
==
Attachment (PublicKey.asc): application/x-apple-msg-attachment, 23 KiB

On Apr 16, 2012, at 5:50 PM, Mait <mattengi <at> gmail.com> wrote:

> ENV
> 
> Ubuntu 12.04
> haskell-platform/precise uptodate 2012.1.0.0~debian
> 
> ghci --version
> The Glorious Glasgow Haskell Compilation System, version 7.4.1
> 
> I've tried all day with,
> 'Learn You a Haskell for Great Good!'
> http://learnyouahaskell.com/
> 
> Very attractive book. I'm really enjoying this book.
> 
> Anyway I have one question,
> 
> Why I can't declare func type like books?
> 
> I got always error about 'lacks an accompanying binding', like this,
> 
> Prelude> :l baby.hs
> [1 of 1] Compiling Main             ( baby.hs, interpreted )
> 
> baby.hs:32:1:
>    The type signature for take' lacks an accompanying binding
> Failed, modules loaded: none.
> 
> Here is codepad link,
> http://codepad.org/ttZRBpkL
> 
> Thanks.
> 
> _______________________________________________
> Beginners mailing list
> Beginners <at> haskell.org
> http://www.haskell.org/mailman/listinfo/beginners


On Apr 16, 2012, at 5:50 PM, Mait <mattengi <at> gmail.com> wrote:

> ENV
> 
> Ubuntu 12.04
> haskell-platform/precise uptodate 2012.1.0.0~debian
> 
> ghci --version
> The Glorious Glasgow Haskell Compilation System, version 7.4.1
> 
> I've tried all day with,
> 'Learn You a Haskell for Great Good!'
> http://learnyouahaskell.com/
> 
> Very attractive book. I'm really enjoying this book.
> 
> Anyway I have one question,
> 
> Why I can't declare func type like books?
> 
> I got always error about 'lacks an accompanying binding', like this,
> 
> Prelude> :l baby.hs
> [1 of 1] Compiling Main             ( baby.hs, interpreted )
> 
> baby.hs:32:1:
>    The type signature for take' lacks an accompanying binding
> Failed, modules loaded: none.
> 
> Here is codepad link,
> http://codepad.org/ttZRBpkL
> 
> Thanks.
> 
> _______________________________________________
> Beginners mailing list
> Beginners <at> haskell.org
> http://www.haskell.org/mailman/listinfo/beginners


Gmane