Revision b9202225

b/src/Ganeti/THH.hs
575 575
genReadJSON :: String -> Q Dec
576 576
genReadJSON name = do
577 577
  let s = mkName "s"
578
  body <- [| case JSON.readJSON $(varE s) of
579
               JSON.Ok s' -> $(varE (fromRawName name)) s'
580
               JSON.Error e ->
581
                   JSON.Error $ "Can't parse raw value for type " ++
582
                           $(stringE name) ++ ": " ++ e ++ " from " ++
583
                           show $(varE s)
584
           |]
578
  body <- [| $(varE (fromRawName name)) =<<
579
             readJSONWithDesc $(stringE name) True $(varE s) |]
585 580
  return $ FunD 'JSON.readJSON [Clause [VarP s] (NormalB body) []]
586 581

  
587 582
-- | Generates a JSON instance for a given type.
......
1056 1051
objectReadJSON :: String -> Q Dec
1057 1052
objectReadJSON name = do
1058 1053
  let s = mkName "s"
1059
  body <- [| case JSON.readJSON $(varE s) of
1060
               JSON.Ok s' -> $(varE .mkName $ "load" ++ name) s'
1061
               JSON.Error e ->
1062
                 JSON.Error $ "Can't parse value for type " ++
1063
                       $(stringE name) ++ ": " ++ e
1064
           |]
1054
  body <- [| $(varE . mkName $ "load" ++ name) =<<
1055
             readJSONWithDesc $(stringE name) False $(varE s) |]
1065 1056
  return $ FunD 'JSON.readJSON [Clause [VarP s] (NormalB body) []]
1066 1057

  
1067 1058
-- * Inheritable parameter tables implementation

Also available in: Unified diff