[Haskell-beginners] GHCi won't allow type declaration as shown in LYAHFGG

Brandon Allbery allbery.b at gmail.com
Thu May 31 22:36:10 CEST 2012


On Thu, May 31, 2012 at 3:48 PM, Stan Kulp <stan_kulp at yahoo.com> wrote:

> I have been working my way through "Learn You a Haskell for Greater Good"
> and am stumped when I get to the "Syntax in Functions - Pattern Matching"
> section.
>
> The book shows the following expression...
>
> ghci> lucky :: (Integral a) => a -> **String
>
> ...but when I try to execute it in GHCi I get the following error...
>
> <interactive>:1:1: Not in scope: `lucky'
>
> What am I missing?
>

ghci is intended for interactive evaluation; it doesn't (currently; this
might change in future versions) do declarations the same way you would in
a source file.

You can still do them with do-style let binding:

    Prelude> let lucky :: (Integral a_ => a -> String; lucky = ...

(This all has to fit on a single line unless you use braces and have done
":set +m"; this may also require a recent GHC.)

-- 
brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120531/87f669f4/attachment-0001.htm>


More information about the Beginners mailing list