Skip to content

Various fixes#86

Open
uhoreg wants to merge 6 commits into
solnic:mainfrom
uhoreg:fixes
Open

Various fixes#86
uhoreg wants to merge 6 commits into
solnic:mainfrom
uhoreg:fixes

Conversation

@uhoreg
Copy link
Copy Markdown
Contributor

@uhoreg uhoreg commented Nov 28, 2025

Fixes errors with certain schemas. I don't remember exactly what the schemas were that caused the errors. One of them was a union where one of the types was a custom type that was a cast or a union itself.

Comment thread lib/drops/type.ex
type = new(opts)
constraints =
case type.constraints do
{:and, constraints} -> {:and, constraints ++ infer_constraints(predicates)}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the minimal changes to make this work. But it looks like {:and, constraints} gets treated the same as just constraints, so I wonder if we can just get rid of {:and, ...} everywhere.

Comment thread lib/drops/type/dsl.ex
@doc since: "0.1.0"

@spec type({atom(), []}) :: type()
@spec type({atom(), list()}) :: type()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Elixir docs say that a typespec of [] means an empty list.

Comment thread lib/drops/types/union.ex

defp constrain(%Drops.Types.Cast{input_type: input_type} = type, predicates) do
Map.merge(type, %{
input_type: constrain(input_type, predicates)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if the constraint should be applied to the input type, the output type, or both.

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

Successfully merging this pull request may close these issues.

1 participant