@@ -16,6 +16,8 @@
1616module Database.PostgreSQL.Simple.TypeInfo.Macro
1717 ( mkCompats
1818 , inlineTypoid
19+ , inlineTypoidP
20+ , getTypoid
1921 ) where
2022
2123import Database.PostgreSQL.Simple.TypeInfo.Static
@@ -29,7 +31,7 @@ mkCompats :: [TypeInfo] -> ExpQ
2931mkCompats tys = [| \(Oid x) -> $(caseE [| x |] (map alt tys ++ [catchAll])) |]
3032 where
3133 alt :: TypeInfo -> MatchQ
32− alt ty = match (litP (getTypoid ty)) (normalB [| True |]) []
34+ alt ty = match (inlineTypoidP ty) (normalB [| True |]) []
3335
3436 catchAll :: MatchQ
3537 catchAll = match wildP (normalB [| False |]) []
@@ -40,5 +42,8 @@ mkCompats tys = [| \(Oid x) -> $(caseE [| x |] (map alt tys ++ [catchAll])) |]
4042inlineTypoid :: TypeInfo -> ExpQ
4143inlineTypoid ty = [| Oid $(litE (getTypoid ty)) |]
4244
45+inlineTypoidP :: TypeInfo -> PatQ
46+inlineTypoidP ty = litP (getTypoid ty)
47+
4348getTypoid :: TypeInfo -> Lit
4449getTypoid ty = let (Oid x) = typoid ty in integerL (fromIntegral x)