Noob question.(I'm trying '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 Thanks.

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,
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@haskell.org http://www.haskell.org/mailman/listinfo/beginners

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
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,
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@haskell.org http://www.haskell.org/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

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
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.

Additionally, "take' :: (Ord b, bum b) => b -> [a] -> [a]" should be "take' :: (Ord b, Num b) => b -> [a] -> [a]"
Jack Henahan
jhenahan@uvm.edu
==
Computer science is no more about computers than astronomy is about telescopes.
-- Michael R. Fellows
==
On Apr 16, 2012, at 5:50 PM, Mait
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@haskell.org http://www.haskell.org/mailman/listinfo/beginners
participants (5)
-
aditya siram
-
Jack Henahan
-
Jakub Oboza
-
Kyle Murphy
-
Mait