@@ -16,6 +16,8 @@
16module Database.PostgreSQL.Simple.TypeInfo.Macro
16module Database.PostgreSQL.Simple.TypeInfo.Macro
17 ( mkCompats
17 ( mkCompats
18 , inlineTypoid
18 , inlineTypoid
21import Database.PostgreSQL.Simple.TypeInfo.Static
23import Database.PostgreSQL.Simple.TypeInfo.Static
@@ -29,7 +31,7 @@ mkCompats :: [TypeInfo] -> ExpQ
29mkCompats tys = [| \(Oid x) -> $(caseE [| x |] (map alt tys ++ [catchAll])) |]
31mkCompats tys = [| \(Oid x) -> $(caseE [| x |] (map alt tys ++ [catchAll])) |]
31 alt :: TypeInfo -> MatchQ
33 alt :: TypeInfo -> MatchQ
32− alt ty = match (litP (getTypoid ty)) (normalB [| True |]) []
34+ alt ty = match (inlineTypoidP ty) (normalB [| True |]) []
34 catchAll :: MatchQ
36 catchAll :: MatchQ
35 catchAll = match wildP (normalB [| False |]) []
37 catchAll = match wildP (normalB [| False |]) []
@@ -40,5 +42,8 @@ mkCompats tys = [| \(Oid x) -> $(caseE [| x |] (map alt tys ++ [catchAll])) |]
40inlineTypoid :: TypeInfo -> ExpQ
42inlineTypoid :: TypeInfo -> ExpQ
41inlineTypoid ty = [| Oid $(litE (getTypoid ty)) |]
43inlineTypoid ty = [| Oid $(litE (getTypoid ty)) |]
45+inlineTypoidP :: TypeInfo -> PatQ
46+inlineTypoidP ty = litP (getTypoid ty)
43getTypoid :: TypeInfo -> Lit
48getTypoid :: TypeInfo -> Lit
44getTypoid ty = let (Oid x) = typoid ty in integerL (fromIntegral x)
49getTypoid ty = let (Oid x) = typoid ty in integerL (fromIntegral x)