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

Generate moat list from haskell set #78

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

josephsumabat
Copy link
Contributor

Aeson automatically converts Haskell sets to json lists. This performs the same conversion for moat allowing us to have records that are correct by construction in Haskell rather than converting to lists.

@@ -117,6 +118,9 @@ instance {-# OVERLAPPABLE #-} forall a. ToMoatType a => ToMoatType [a] where

instance {-# OVERLAPPING #-} ToMoatType [Char] where toMoatType _ = Str

instance forall a. ToMoatType a => ToMoatType (Set a) where
toMoatType _ = Array (toMoatType (Proxy @a))
Copy link
Contributor Author

@josephsumabat josephsumabat Feb 12, 2024

Choose a reason for hiding this comment

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

Maybe there's a more appropriate set type for ios and android that can be parsed from a json list? @kylebshr @tadfisher . I think it's fine to do this though imo since the json is a list.

Copy link
Collaborator

Choose a reason for hiding this comment

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

On Android it's just Set<A>, so the existing conversion works as is.

Copy link
Collaborator

@chiroptical chiroptical left a comment

Choose a reason for hiding this comment

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

Assuming Kyle and Tad don't have any objections

@josephsumabat josephsumabat force-pushed the joseph/moat-set-instance branch from aafd4cd to ac21c06 Compare February 13, 2024 20:25
@josephsumabat josephsumabat merged commit bfbce76 into master Feb 14, 2024
21 checks passed
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.

3 participants