Skip to content

Conversation

@mchaver
Copy link

@mchaver mchaver commented Oct 2, 2024

#20

This isn't complete but I wanted to make sure it is going in the right direction before completing it. Things to note:

  1. safeTo creates a SafeValue. I wasn't sure if safeFrom should take Value or SafeValue.
  2. I think the SafeValue constructor should not be exported. Just the type and the unSafeValue field.

@Vlix
Copy link
Owner

Vlix commented Oct 15, 2024

Ah, thank you for the effort. 🙏

I'll try to look at this when I have some free time (hopefully in the next month)

Copy link
Owner

@Vlix Vlix left a comment

Choose a reason for hiding this comment

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

The SafeValue should also be exported from Data.SafeJSON. And we'll also need an instance SafeJSON SafeValue.

I don't think we'd have to hide the data constructor of SafeValue when exporting, since it's trivial for anyone to create a SafeValue from a regular Value anyway. (because of the instance SafeJSON Value)

version = noVersion

-- | @since 1.1.2.0
instance (SafeJSON (f a), SafeJSON (g a)) => SafeJSON (Sum f g a) where
Copy link
Owner

Choose a reason for hiding this comment

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

Why did you comment out this instance?

-- @since 1.0.0
removeVersion :: Value -> Value
removeVersion = \case
-- removeVersion :: SafeValue -> Value
Copy link
Owner

Choose a reason for hiding this comment

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

This commented-out section can be removed, right?

--
-- @since 1.0.0
setVersion' :: forall a. SafeJSON a => Version a -> Value -> Value
setVersion' :: forall a. SafeJSON a => Version a -> SafeValue -> SafeValue
Copy link
Owner

Choose a reason for hiding this comment

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

I designed the setVersion functions to mainly be used to set the version when the value does not have one (taking a format from a third party who doesn't need to know about the versioning, for example)

So I'd say it would be more logical for the type to be Value -> SafeValue

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.

2 participants