
On Wed, 17 Jan 2007 15:58:04 +0300
Max Vasin
Hello all!
Let
data Book = Book { authors :: [String], title :: String, editor :: Maybe String, edition :: Maybe String, volume :: Maybe (Int, Int), -- e.g. volume 1 of 3 publisher :: String, year :: Int, pages :: Int }
One suggestion: why not make the Book type more general, e.g. a list of labeled fields:
data Label = Author | Title | Editor | .... type Field = String newtype Book = Book [(Label,Field)]
The idea is that e.g. multiple authors would be represented by multiple entries with an "Author" label and optional fields can be omitted. Then the empty book is simply
empty = Book []
You might also find that this makes the processing of fields more uniform and easier to extend. Best regards, Pedro Vasconcelos.