
"Pedro" == Pedro Baltazar Vasconcelos
writes:
Pedro> On Wed, 17 Jan 2007 15:58:04 +0300
Pedro> 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)]
Pedro> The idea is that e.g. multiple authors would be represented Pedro> by multiple entries with an "Author" label and optional Pedro> fields can be omitted. Then the empty book is simply It does not enforce presence of required fields at type level. Also it does not enforce that fields pages and year are Int. And I want to move as much checks to compile time as possible. -- WBR, Max Vasin.