summaryrefslogtreecommitdiff
path: root/src/Settlr/Storage.hs
blob: 53c29b7d6f21705b4612b9cd1a9f647a980e940a (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
module Settlr.Storage
  ( Group(..)
  , Member(..)
  , Money(..)
  , Currency(..)
  , GroupMetadata(..)
  , getMetadata
  , createGroup
  , deleteGroup
  , Expense(..)
  , getExpenses
  , getSaldo
  , addExpense
  ) where

import Data.Text (Text)
import Data.Map (Map)

-- Identifier of a group.
newtype Group = Group Text

-- Identifier of a group member.
newtype Member = Member Text

-- An amount of money in a particular currency (usually, the smallest unit for the currency).
newtype Money = Money Int

data Currency = CurrencyEUR | CurrencyUSD

data GroupMetadata = GroupMetadata
  { grpName     :: !Text
  , grpMembers  :: ![Member]
  , grpCurrency :: !Currency
  }

getMetadata :: Group -> IO GroupMetadata
getMetadata = undefined

createGroup :: GroupMetadata -> IO Group
createGroup = undefined

deleteGroup :: Group -> IO ()
deleteGroup = undefined

data Expense = Expense
  { expCreditor :: !Member
  , expDebtors  :: !(Map Member Money)
  }

getExpenses :: Group -> IO [Expense]
getExpenses = undefined

getSaldo :: Group -> Member -> IO Money
getSaldo = undefined

addExpense :: Group -> Expense -> IO ()
addExpense = undefined