We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I've managed to get it via generics-sop, but I don't have much experience in this stuff.
data T a = T { field_reps :: Int , field_what :: Text , field_ignore :: Char , field_inside :: a } deriving (Show, Eq) deriveGeneric ''T -- SOP -- relies on unjsonDef for all fields unjT :: (Typeable a, Unjson a) => UnjsonDef (T a) unjT = gunjson do T.stripPrefix "field_" do [ "number of repetitions" , "string to repeat" , "char to ignore" , "inside the T" ] do T -- specify unjsonDef per field unjUT :: (Typeable a, Unjson a) => UnjsonDef (T a) unjUT = gunjsonU do T.stripPrefix "field_" do C "number of repetitions" unjsonDef :* C "string to repeat" do invmap T.reverse T.reverse unjsonDef :* C "char to ignore" unjsonDef :* C "inside the T" unjsonDef :* Nil do T instance (Typeable a, Unjson a) => Unjson (T a) where unjsonDef = unjUT testV = T 54 "mamma" 'a' (T 32 "piero" 'p' (128 :: Int)) roundTest :: forall a. (Unjson a, Eq a) => a -> Bool roundTest x = (parse unjsonDef . traceShowId . unjsonToJSON unjsonDef) x == Result x []
If you think it can be good to have, I can file a MR
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I've managed to get it via generics-sop, but I don't have much experience in this stuff.
If you think it can be good to have, I can file a MR
The text was updated successfully, but these errors were encountered: