-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathBuilder.hs
More file actions
30 lines (25 loc) · 836 Bytes
/
Builder.hs
File metadata and controls
30 lines (25 loc) · 836 Bytes
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
module Builder where
-- accountNo, Name, branch, balance, interestRate
data BankAccount = BankAccount {
accountNo :: Int
, name :: String
, branch :: String
, balance :: Double
, interestRate :: Double
} deriving (Show)
buildAccount :: Int -> BankAccount
buildAccount i = BankAccount i "Dummy Customer" "London" 0 0
builderDemo = do
putStrLn "Builder -> record syntax, smart constructor"
let account = buildAccount 1234
print account
let account1 = account {name="Marjin Mejer", branch="Paris", balance=10000, interestRate=2}
print account1
let account2 = BankAccount {
accountNo = 5678
, name = "Marjin Mejer"
, branch = "Reikjavik"
, balance = 1000
, interestRate = 2.5
}
print account2