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

Un-exposing Schema constructors #13

Open
bergmark opened this issue Sep 4, 2014 · 1 comment
Open

Un-exposing Schema constructors #13

bergmark opened this issue Sep 4, 2014 · 1 comment

Comments

@bergmark
Copy link
Member

bergmark commented Sep 4, 2014

There are some things you can construct by using the constructors directly that don't make sense, aren't useful, or can be represented in several ways

Choice [] -- Doesn't match anything
Choice [foo,foo] = foo
Choice [Choice foo] = Choice [foo]
Tuple [] = Constant (Aeson.Array Vector.empty) = Array (LengthtBound (Just 0) (Just 0))
Null -- Same as Constant Aeson.Null
LengthBound (Just -2) (Just -1) -- Doesn't match anything

Some of these are hard to fix we can not (afaict) use a (Hash)Set for Choice since Aeson doesn't implement Ord or Hashable.

We can fix some of this by unexposing the constructors and only using smart constructors instead, <|> for Choice, <+> for Tuple, Value etc could have a Maybe Bound instead so you can create one by doing mkBound <$> foo 1 <*> foo 2.

I'm going to remove Null in the next release, but I'll let the rest air out for a bit.

@bergmark
Copy link
Member Author

bergmark commented Sep 4, 2014

But i just realized that if you want to inspect the schema you probably want the constructors, so we need to leave them exposed, but perhaps not from the top level module and instead expose the combinators from there.

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