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

Wrap id types for type safety #55

Open
ThomasWeiser opened this issue Nov 27, 2016 · 3 comments
Open

Wrap id types for type safety #55

ThomasWeiser opened this issue Nov 27, 2016 · 3 comments

Comments

@ThomasWeiser
Copy link
Contributor

Instead of

type alias Proposal =
    { id : String
    , ...
    }

we should use

type alias Proposal =
    { id : ProposalId
    , ...
    }
type ProposalId = ProposalId String

Same goes for ParticipantId and AccessToken.

This way we strengthen type safety and get better self-documenting code when passing this values around.

@ThomasWeiser
Copy link
Contributor Author

Will have to check if it's worthwhile or too much boilerplate.
Deferred for now.

@ThomasWeiser
Copy link
Contributor Author

Recently Richard Feldman wrote that union types may get comparable sometime.

Working with wrapped types would become much easier then and we should use them for type safety.

@oliverbarnes
Copy link
Collaborator

Sounds good.

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

No branches or pull requests

2 participants