Skip to content

Un-exposing Schema constructors #13

Description

@bergmark

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions