Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDBC DomainAPI #40

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

HDBC DomainAPI #40

wants to merge 9 commits into from

Conversation

jfoutz
Copy link

@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
Contributor

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

@jfoutz
Copy link
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
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
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