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

Make sturctures with default values irrepresentable, use Maybe to demonstrate absence of value rather than a struct with default nonsense. #24

Open
2 tasks
cognivore opened this issue Aug 15, 2023 · 0 comments

Comments

@cognivore
Copy link
Contributor

Why?

We're using a neat hack to create default temporary structures when we don't have enough information to create a filled one.

For example, have a look at code in lib/zhr_devs/submissions/aggregates/submission.ex:57

It's not a good design. If something doesn't make sense to have a default value of type a, then either that field of the thing has to be Nothing or Just a, or, sometimes, the whole thing should be Maybe (Thing a)

How

  • Tweak Maybe in Algae so that it preserves the underlying type information (see Uptight.Result.sum(e, a)). Ensure backwards-compatibility.
  • Replace structures and field with Maybes in zhr_devs
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

1 participant