Skip to content

Instantly share code, notes, and snippets.

@choonkeat
Last active October 6, 2021 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choonkeat/da0b72485235d244dca0ee4bb75097ed to your computer and use it in GitHub Desktop.
Save choonkeat/da0b72485235d244dca0ee4bb75097ed to your computer and use it in GitHub Desktop.
Custom Type Naming Convention (hope I can gist search this time; wrote it before)

In a type specific module, we can name succinctly

module Channel

type Channel
    = Alpha
    | Beta

other code will reference like such

otherModule : Channel.Channel
otherModule =
    Channel.Alpha 

in a shared/container module, it's usually better to namespace variants

module Communication 

type Channel
    = ChannelAlpha
    | ChannelBeta

-- and avoid conflict 
type Callsign
    = CallsignAlpha
    | CallsignBeta

other code will reference like such

otherModule : Communication.Channel
otherModule =
    Communication.ChannelAlpha 

even if we had let type Channel win and keep the succinct Alpha name, and only namespace type Callsign = CallsignAlpha | CallsignBeta, when other code references Communication.Alpha it would've been ambiguous anyways.

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