participateapp / web-client

Participate! is an app for democratic decision making
MIT License
6 stars 1 forks source link

Wrap id types for type safety #55

Open ThomasWeiser opened 7 years ago

ThomasWeiser commented 7 years ago

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 commented 7 years ago

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

ThomasWeiser commented 7 years ago

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 commented 7 years ago

Sounds good.