servant-util-0.2: Servant servers utilities.
Safe HaskellNone
LanguageHaskell2010

Servant.Util.Combinators.Filtering.Backend

Description

Provides base for filtering backend implementations.

Synopsis

Filtering backend

class FilterBackend backend Source #

Implementation of filtering backend.

Associated Types

type AutoFilteredValue backend a Source #

The part of object which we are filtering on, provided by server backend implementor.

type MatchPredicate backend Source #

A resulting predicate.

type AutoFilterImpl backend a = AutoFilteredValue backend a -> MatchPredicate backend Source #

Implementation of auto filter we provide.

data FilteringApp backend param where Source #

How to apply a filter - what server backend implementor provides.

Constructors

AutoFilteringApp :: Typeable a => AutoFilteredValue backend a -> FilteringApp backend ('TyNamedParam name ('AutoFilter a)) 
ManualFilteringApp :: Typeable a => (a -> MatchPredicate backend) -> FilteringApp backend ('TyNamedParam name ('ManualFilter a)) 

class (Typeable filter, FilterBackend backend) => AutoFilterSupport backend filter a where Source #

Implementation of given auto filter type for Beam Postgres backend.

Methods

autoFilterSupport :: filter a -> AutoFilterImpl backend a Source #

Apply given filter to a value.

type FilteringSpecApp backend params = HList (FilteringApp backend) params Source #

Enlists a way to apply each of supported filters at target application backend.

class FilterBackend backend => BackendApplySomeFilter backend (params :: [TyNamedFilter]) Source #

Lookups for an appropriate filter application in a given FilteringSpecApp and applies it to a given filter.

Minimal complete definition

backendApplySomeFilter'

Instances

Instances details
FilterBackend backend => BackendApplySomeFilter (backend :: k) ('[] :: [TyNamedFilter]) Source # 
Instance details

Defined in Servant.Util.Combinators.Filtering.Backend

Methods

backendApplySomeFilter' :: FilteringSpecApp backend '[] -> SomeFilter '[] -> Maybe (MatchPredicate backend)

(Typeable fk, Typeable a, FilterBackend backend, KnownSymbol name, BackendApplyTypeFilter backend fk a, BackendApplySomeFilter backend params) => BackendApplySomeFilter (backend :: k) ('TyNamedParam name (fk a) ': params) Source # 
Instance details

Defined in Servant.Util.Combinators.Filtering.Backend

Methods

backendApplySomeFilter' :: FilteringSpecApp backend ('TyNamedParam name (fk a) ': params) -> SomeFilter ('TyNamedParam name (fk a) ': params) -> Maybe (MatchPredicate backend)

typeAutoFiltersSupport :: forall backend a. TypeAutoFiltersSupport backend a => SomeTypeAutoFilter a -> AutoFilterImpl backend a Source #

Safely choose an appropriate filter from supported ones and prepare it for application.

backendApplyFilters :: forall backend params. BackendApplySomeFilter backend params => FilteringSpec params -> FilteringSpecApp backend params -> [MatchPredicate backend] Source #

Applies multiple filters to a set of response fields which matter for filtering.

Server backend implementor API

filterOn :: forall name backend a. Typeable a => AutoFilteredValue backend a -> FilteringApp backend ('TyNamedParam name ('AutoFilter a)) Source #

Implement an automatic filter. User-provided filtering operation will do filter on this value.

manualFilter :: forall name backend a. Typeable a => (a -> MatchPredicate backend) -> FilteringApp backend ('TyNamedParam name ('ManualFilter a)) Source #

Implement a manual filter. You are provided with a value which user supplied and so you have to construct a Beam predicate involving that value and relevant response fields.