withType :: Name -> (Name -> [TyVarBndr] -> [Con] -> Q a) -> Q a
withType name f = do
  let ns = "Network.AuthorizeNet.TH.withType: "
  info <- reify name
  case info of
    TyConI dec ->
      case dec of
        DataD    _ _ tvbs cons _ -> f name tvbs cons
        NewtypeD _ _ tvbs con _  -> f name tvbs [con]
        other -> error $ ns ++ "Unsupported type: " ++ show other
    _ -> error $ ns ++ "Data constructor " ++ show name ++ " is not from a data or newtype constructor"
withType :: Name -> (Name -> [TyVarBndr] -> [Con] -> Q a) -> Q a
withType name f = do
  let ns = "Network.AuthorizeNet.TH.withType: "
  info <- reify name
  case info of
    TyConI dec ->
      case dec of
        DataD    _ _ tvbs cons _ -> f name tvbs cons
        NewtypeD _ _ tvbs con _  -> f name tvbs [con]
        other -> error $ ns ++ "Unsupported type: " ++ show other
    _ -> error $ ns ++ "Data constructor " ++ show name ++ " is not from a data or newtype constructor"
withType name f = do
  let ns = "Network.AuthorizeNet.TH.withType: "
  info <- reify name
  case info of
    TyConI dec ->
      case dec of
        DataD    _ _ tvbs cons _ -> f name tvbs cons
        NewtypeD _ _ tvbs con _  -> f name tvbs [con]
        other -> error $ ns ++ "Unsupported type: " ++ show other
    _ -> error $ ns ++ "Data constructor " ++ show name ++ " is not from a data or newtype constructor"