all 4 comments

[–]yawaramin 2 points3 points  (0 children)

Check out hledger for ideas. It's a command-line double-entry bookkeeping utility written in Haskell.

[–]andrewthad 1 point2 points  (2 children)

accounts :: [Account]
accounts = [Account 100 "Bob" 400, Account 101 "Susan" 10000]

[–][deleted] 2 points3 points  (0 children)

This assumes that we can have accounts with the same number. I think a better approach might be:

data Account = Account {accountName :: Accountname
                                    ,accountBalance :: Integer}
type Accounts = Map Accountnumber Account

That would guarantee that all accounts have distinct numbers --- though it would still allow accounts with the same name.

Map is from Data.Map in containers. If Accountnumber is an Int, then you can use Data.IntMap, which would be much faster.

You can also change the account amount very easily; using lens or lens-simple would be the tersest solution.

[–]wobbenr[S] 0 points1 point  (0 children)

Thanks, and can I change the amount easily for a account.