-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBookStore.hs
37 lines (30 loc) · 1.18 KB
/
BookStore.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
type CustomerID = Int
type ReviewBody = String
type BookRecord = (BookInfo, BookReview)
data BookInfo = Book Int String [String] deriving (Show)
data MagazineInfo = Magazine Int String [String] deriving (Show)
data BookReview = BookReview BookInfo CustomerID ReviewBody
type CardHolder = String
type CardNumber = String
type Address = [String]
data BillingInfo = CreditCard CardNumber CardHolder Address
| CashOnDelivery
| Invoice CustomerID
deriving (Show)
myInfo = Book 9780135072455 "Algebra of Programming" ["Richard Bird",
"Oege de Moor"]
bookID (Book id title authors) = id
bookTitle (Book id title authors) = title
bookAuthors (Book id title authors) = authors
data Customer = Customer {
customerID :: CustomerID,
customerName :: String,
customerAddress :: Address
} deriving (Show)
customer1 = Customer 2718 "J.R. Hacker"
["255 Syntax Ct", "Milpitas, CA 95134", "USA"]
customer2 = Customer {
customerID = 271828
, customerAddress = ["blah", "hermph", "Foo"]
, customerName ="Jane Q. Citizen"
}