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

Add newtype wrappers to fix scale/rate confusion #73

Open
Shimuuar opened this issue Feb 1, 2015 · 1 comment
Open

Add newtype wrappers to fix scale/rate confusion #73

Shimuuar opened this issue Feb 1, 2015 · 1 comment

Comments

@Shimuuar
Copy link
Collaborator

Shimuuar commented Feb 1, 2015

We have several functions which could take either scale or rate parameter. For example exponential distribution. I can never remember which should be used. I think we shold use type system to encode which kind of parameter should be used. It's also conveninent to be able to pass either rate or scale parameter. So I propose following design:

newtype Rate = Rate Double
newtype Scale = Scale Double

class RateOrScale a where
  toRateParameter :: a → Double
  toScaleParameter :: a → Double

Name of type class is hmm... not ideal.

@Shimuuar
Copy link
Collaborator Author

another option is:

data RateOrScale {- or any better name -}
  = Rate Double
  | Scale Double

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

No branches or pull requests

1 participant