Skip to content

HDBC DomainAPI#40

Open
jfoutz wants to merge 9 commits intovacationlabs:masterfrom
jfoutz:master
Open

HDBC DomainAPI#40
jfoutz wants to merge 9 commits intovacationlabs:masterfrom
jfoutz:master

Conversation

@jfoutz
Copy link
Copy Markdown

@jfoutz jfoutz commented Oct 25, 2016

I'm interested in DomainAPI and Types

I think maybe each primitive type in Tenant and User should become a type alias, and the "create" versions should take typed arguments rather than a tennant or a user. I don't think ignoring arguments is bad but it's not great.

@saurabhnanda
Copy link
Copy Markdown
Contributor

@jfoutz unable to compile your code because of the missing cabal file. Did you forget to commit?

@jfoutz
Copy link
Copy Markdown
Author

jfoutz commented Oct 26, 2016

Yes. Added and pushed. This should cover the DomainAPI only, i'll have another update for design goals tomorrow. (at least some of the design goals will move to the next sprint.)

mkData6 f (x1:x2:x3:x4:x5:x6:[]) = Just $ f (fromSql x1) (fromSql x2) (fromSql x3) (fromSql x4) (fromSql x5) (fromSql x6)
mkData9 f (x1:x2:x3:x4:x5:x6:x7:x8:x9:[]) = Just $ f (fromSql x1) (fromSql x2) (fromSql x3) (fromSql x4) (fromSql x5) (fromSql x6) (fromSql x7) (fromSql x8) (fromSql x9)
mkData9 _ _ = Nothing
mkData11 f (x1:x2:x3:x4:x5:x6:x7:x8:x9:x10:x11:[]) = Just $ f (fromSql x1) (fromSql x2) (fromSql x3) (fromSql x4) (fromSql x5) (fromSql x6) (fromSql x7) (fromSql x8) (fromSql x9) (fromSql x10) (fromSql x11)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any way to write these functions so that they work with lists of exactly N elements? Does HDBC have functions which return fixed sized tuples instead of lists?

_ -> Nothing

createTenant :: Connection -> Tenant -> IO (Maybe Int)
createTenant conn (Tenant _ created updated name first last email phone status owner backoffice) = do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't using the record constructor a much safer way of pattern matching this? It protects against change in position of fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants