[Haskell-beginners] Strange gchi behavior?
Olwe Melwasul
galaxybeingplan9 at gmail.com
Thu Mar 15 05:28:02 CET 2012
I'm working my way through Real World Haskell and am in Chapter 3. On page
56 there is a discussion called "Record Syntax" and it gives this data
constructor:
data Customer = Customer {
customerID :: CustomerID
, customerName :: String
, customerAddress :: Address
} deriving (Show)
where CustomerID and Address were defined (and loaded) before. But when I
try to put in data, I get these errors
*Main> :load BookStore.hs
[1 of 1] Compiling Main ( BookStore.hs, interpreted )
Ok, modules loaded: Main.
*Main> customer1 = Customer 271828 "J.R. Hacker"
["255 Syntax Ct",
"Milpitas, CA 95134",
"USA"]
<interactive>:1:11: parse error on input `='
*Main>
<interactive>:1:18: parse error (possibly incorrect indentation)
*Main>
<interactive>:1:21: parse error on input `,'
*Main>
<interactive>:1:6: parse error on input `]'
*Main>
If I put the whole data add on one line, I still get
*Main> customer1 = Customer 271828 "J.R. Hacker" ["255 Syntax Ct",
"Milpitas, CA 95134", "USA"]
<interactive>:1:11: parse error on input `='
*Main>
I'm on Ubuntu 11.10, using Emacs23, haskell-mode, running 7.0.4. Any ideas
what's going wrong? The book gives this alternate version:
data Customer = Customer Int String [String]
deriving (Show)
customerID :: Customer -> Int
customerID (Customer id _ _) = id
customerName :: Customer -> String
customerName (Customer _ name _) = name
customerAddress :: Customer -> [String]
customerAddress (Customer _ _ address) = address
...but it produces the same errors.
Olwe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120314/19ea5453/attachment.htm>
More information about the Beginners
mailing list