Skip to content

Add valid functions #406

Open
Open

Description

@phadej
-- check invariants
valid :: Text -> Bool

For strict text it would check that array is big enough to have offset+length, and that the slice is valid utf8.

For lazy text it would check the above, and chunk invariants.

These functions would be very useful (in writing tests) when one tinkers with internals. (Either in text itself, or other packages).

There are strictInvariant and lazyVariant for lazy text, but they error. Not entirely, but almost useless in tests.

Activity

  1. Bodigrim commented on Jan 9, 2022

    @Bodigrim
    Contributor

    I'd prefer isValid, but otherwise I'm in favor of this.

  2. phadej commented on Jan 9, 2022

    @phadej
    ContributorAuthor

    valid is inspired by the name in containers. Whatever works.

    Also: https://hackage.haskell.org/package/perhaps-0/docs/Data-Perhaps.html is one nice way to combine error messages with Bool. (That would be great, but not worth dependency, just FYI).

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