groundhog-0.2.0: Type-safe ADT-database mapping library.

Safe HaskellNone

Database.Groundhog.Expression

Description

This module provides mechanism for flexible and typesafe usage of plain data values and fields. The expressions can used in conditions and right part of Update statement. Example:

 StringField ==. "abc" &&. NumberField >. (0 :: Int) ||. MaybeField ==. (Nothing :: Maybe String) ||. MaybeField ==. Just "def"

Note that polymorphic values like numbers or Nothing must have a type annotation

Synopsis

Documentation

class Expression a v c whereSource

Instances of this type can be converted to Expr. It is useful for uniform manipulation over fields and plain values

Methods

toExpression :: a -> Expr v c aSource

Instances

PurePersistField a => Expression a v c 
(PersistEntity v, Constructor c, FieldLike (u (UniqueMarker v)) (RestrictionHolder v c) a', ~ ((* -> *) -> *) c' (UniqueConstr (Key v' (Unique u))), ~ * v v', IsUniqueKey (Key v' (Unique u)), ~ ((* -> *) -> *) c c') => Expression (u (UniqueMarker v)) v' c' 
(PersistEntity v, Constructor c, PersistField (Key v' BackendSpecific), FieldLike (AutoKeyField v c) (RestrictionHolder v c) a', ~ * v v', ~ ((* -> *) -> *) c c') => Expression (AutoKeyField v c) v' c' 
(PersistEntity v, Constructor c, PersistField a, ~ * v v', ~ ((* -> *) -> *) c c') => Expression (Arith v c a) v' c' 
(PersistEntity v, Constructor c, PersistField a, ~ * v v', ~ ((* -> *) -> *) c c') => Expression (SubField v c a) v' c' 
(PersistEntity v, Constructor c, PersistField a, ~ * v v', ~ ((* -> *) -> *) c c') => Expression (Field v c a) v' c' 

(=.) :: (Expression b v c, FieldLike f (RestrictionHolder v c) a', Unifiable f b) => f -> b -> Update v cSource

Update field

(&&.) :: Cond v c -> Cond v c -> Cond v cSource

Boolean "and" operator.

(||.) :: Cond v c -> Cond v c -> Cond v cSource

Boolean "or" operator.

(==.) :: (Expression a v c, Expression b v c, Unifiable a b) => a -> b -> Cond v cSource

(/=.) :: (Expression a v c, Expression b v c, Unifiable a b) => a -> b -> Cond v cSource

(<.) :: (Expression a v c, Expression b v c, Unifiable a b) => a -> b -> Cond v cSource

(<=.) :: (Expression a v c, Expression b v c, Unifiable a b) => a -> b -> Cond v cSource

(>.) :: (Expression a v c, Expression b v c, Unifiable a b) => a -> b -> Cond v cSource

(>=.) :: (Expression a v c, Expression b v c, Unifiable a b) => a -> b -> Cond v cSource