@@ -28,6 +28,7 @@ Type expressions.
2828module Squeal.PostgreSQL.Expression.Type
2929 ( TypeExpression (..)
3030 , cast
31+ , astype
3132 , PGTyped (..)
3233 , typedef
3334 , typetable
@@ -100,6 +101,17 @@ cast
100101cast ty x = UnsafeExpression $ parenthesized $
101102 renderSQL x <+> "::" <+> renderSQL ty
102103
104+-- | A safe version of `cast` which just matches a value with its type.
105+--
106+-- >>> printSQL (1 & astype int)
107+-- (1 :: int)
108+astype
109+ :: TypeExpression schemas ty
110+ -- ^ type to specify as
111+ -> Expression outer commons grp schemas params from ty
112+ -- ^ value
113+ -> Expression outer commons grp schemas params from ty
114+astype = cast
103115
104116{-----------------------------------------
105117type expressions