update in-place

Cagdas Ozgenc co19@cornell.edu
Tue, 2 Oct 2001 17:14:07 +0300


 > data Foo = Foo { a :: Int, b :: String }
 >
 > instance Show Foo where
 >   show f = show (a f) ++ " " ++ show (b f)
 >
 > foo = Foo { a = 99, b = "green bottles\n" }
 >
 > main = do print foo
 >           let bar = foo { a = 98 }
 >           print bar

The above code is from Haskell FAQ. I could not find the "data Foo = Foo
 }" notation in my Haskell, The Craft of Functional Programming book. What
does it mean?

Also

 > instance Show Foo where
 >   show f = show (a f) ++ " " ++ show (b f)

I do not understand show (a f) either. And same goes for "foo { a = 98 }"
notation.

Could you help me on this notation?

Thanks