Copyright | (c) Gareth Tan 2017 |
---|---|

License | MIT |

Safe Haskell | None |

Language | Haskell2010 |

Assorted internal utilities.

- alt :: Alternative f => (a -> a -> a) -> f a -> f a -> f a
- andMaybe :: [Maybe Bool] -> Maybe Bool
- computeMaximumConstraints :: [Maybe Scientific] -> [Maybe Bool] -> (Maybe Scientific, Maybe Bool)
- computeMinimumConstraints :: [Maybe Scientific] -> [Maybe Bool] -> (Maybe Scientific, Maybe Bool)
- zipWithPadding :: a -> b -> [a] -> [b] -> [(a, b)]
- listToMaybeList :: [a] -> Maybe [a]
- setToMaybeSet :: Set a -> Maybe (Set a)
- parseValue :: ByteString -> Value
- printSchema :: Schema -> Text

# Documentation

alt :: Alternative f => (a -> a -> a) -> f a -> f a -> f a Source #

Functions like an Applicative but keeps the `Just`

value if it exists.

andMaybe :: [Maybe Bool] -> Maybe Bool Source #

Returns the and of the Just values or Nothing if there are no Justs

computeMaximumConstraints :: [Maybe Scientific] -> [Maybe Bool] -> (Maybe Scientific, Maybe Bool) Source #

The unification function for the integer constraints `maximum`

and `exclusiveMaximum`

.
When unifying schemas the `exclusiveMaximum`

may somestimes need to be modified
based on the @maximum.

computeMinimumConstraints :: [Maybe Scientific] -> [Maybe Bool] -> (Maybe Scientific, Maybe Bool) Source #

The unification function for the integer constraints `minimum`

and `exclusiveMinimum`

.
When unifying schemas the `exclusiveMinimum`

may somestimes need to be modified
based on the @minimum.

zipWithPadding :: a -> b -> [a] -> [b] -> [(a, b)] Source #

Zips a list but uses the default value if one list is longer than the other.

listToMaybeList :: [a] -> Maybe [a] Source #

Similar to `listFromMaybe`

, but returns the entire list as a
`Just`

if it is not empty instead of only the first item.

setToMaybeSet :: Set a -> Maybe (Set a) Source #

Returns the entire set as a `Just`

if it is not empty
instead of only one item.

parseValue :: ByteString -> Value Source #

Parses a bytestring to a value.

printSchema :: Schema -> Text Source #

Converts a schema to text.