iijlab / direct-hs

Client library for https://direct4b.com in Haskell
8 stars 1 forks source link

Reduce data redundancy #62

Closed yotsuya closed 5 years ago

yotsuya commented 5 years ago

This PR modifies some data types to reduce data redundancy. The purpose of this PR is to make it easy to maintain the integrity of data when handling notifications.

Changes (UPDATE: see https://github.com/iij-ii/direct-hs/pull/62#issuecomment-440606390)

Implementation

Interfaces

Before After
setUsers Client -> [User] -> IO () Client -> Users -> IO ()
getUsers Client -> IO [User] Client -> IO Users
getMe Client -> IO (Maybe User) Client -> IO User
setAcquaintances - :new: Client -> [User] -> IO ()
getAcquaintances - :new: Client -> IO [User]
talkUsers TalkRoom -> [User] :no_entry: removed
getTalkUsers - :new: Client -> TalkRoom -> IO Users
channelTalkRoom Channel -> TalkRoom :no_entry: removed
yotsuya commented 5 years ago

The initial design of PR was changed by the above discussion. So, I summarized the changes again.

Changes

Implementation

Interfaces

Before After
getMe Client -> IO (Maybe User) Client -> IO User
setAcquaintances - :new: Client -> [User] -> IO ()
getAcquaintances - :new: Client -> IO [User]
setUsers Client -> [User] -> IO () :no_entry: removed
talkUsers TalkRoom -> [User] :no_entry: removed
getTalkUsers - :new: Client -> TalkRoom -> IO Users
channelTalkRoom Channel -> TalkRoom :no_entry: removed