opaleye-0.9.2.0: An SQL-generating DSL targeting PostgreSQL
Safe HaskellNone
LanguageHaskell2010

Opaleye.Distinct

Synopsis

Documentation

distinct :: Default Distinctspec fields fields => Select fields -> Select fields Source #

Remove duplicate rows from the Select.

Example type specialization:

distinct :: Select (Field a, Field b) -> Select (Field a, Field b)

Assuming the makeAdaptorAndInstance splice has been run for the product type Foo:

distinct :: Select (Foo (Field a) (Field b) (Field c)) -> Select (Foo (Field a) (Field b) (Field c))

If you want to run distinct on SelectArrs you should apply laterally to it:

laterally distinct :: Default Distinctspec fields fields => SelectArr i fields -> SelectArr i fields

distinctOn :: Default Unpackspec b b => (a -> b) -> Select a -> Select a Source #

Keep a row from each set where the given function returns the same result. No ordering is guaranteed. Multiple fields may be distinguished by projecting out tuples of Field_s. Use distinctOnBy to control how the rows are chosen.

distinctOnBy :: Default Unpackspec b b => (a -> b) -> Order a -> Select a -> Select a Source #

Keep the row from each set where the given function returns the same result. The row is chosen according to which comes first by the supplied ordering. However, no output ordering is guaranteed. Mutliple fields may be distinguished by projecting out tuples of Field_s.

Explicit versions

distinctExplicit :: Distinctspec fields fields' -> Select fields -> Select fields' Source #

Adaptors

data Distinctspec a b Source #

Instances

Instances details
Profunctor Distinctspec Source # 
Instance details

Defined in Opaleye.Internal.Distinct

Methods

dimap :: (a -> b) -> (c -> d) -> Distinctspec b c -> Distinctspec a d #

lmap :: (a -> b) -> Distinctspec b c -> Distinctspec a c #

rmap :: (b -> c) -> Distinctspec a b -> Distinctspec a c #

(#.) :: forall a b c q. Coercible c b => q b c -> Distinctspec a b -> Distinctspec a c #

(.#) :: forall a b c q. Coercible b a => Distinctspec b c -> q a b -> Distinctspec a c #

ProductProfunctor Distinctspec Source # 
Instance details

Defined in Opaleye.Internal.Distinct

Methods

purePP :: b -> Distinctspec a b #

(****) :: Distinctspec a (b -> c) -> Distinctspec a b -> Distinctspec a c #

empty :: Distinctspec () () #

(***!) :: Distinctspec a b -> Distinctspec a' b' -> Distinctspec (a, a') (b, b') #

SumProfunctor Distinctspec Source # 
Instance details

Defined in Opaleye.Internal.Distinct

Methods

(+++!) :: Distinctspec a b -> Distinctspec a' b' -> Distinctspec (Either a a') (Either b b') #

Default (WithNulls Distinctspec) a b => Default Distinctspec (MaybeFields a) (MaybeFields b) Source # 
Instance details

Defined in Opaleye.Internal.Distinct

Default Distinctspec (Field_ n a) (Field_ n a) Source # 
Instance details

Defined in Opaleye.Internal.Distinct

Methods

def :: Distinctspec (Field_ n a) (Field_ n a) #

Functor (Distinctspec a) Source # 
Instance details

Defined in Opaleye.Internal.Distinct

Methods

fmap :: (a0 -> b) -> Distinctspec a a0 -> Distinctspec a b #

(<$) :: a0 -> Distinctspec a b -> Distinctspec a a0 #

Applicative (Distinctspec a) Source # 
Instance details

Defined in Opaleye.Internal.Distinct

Methods

pure :: a0 -> Distinctspec a a0 #

(<*>) :: Distinctspec a (a0 -> b) -> Distinctspec a a0 -> Distinctspec a b #

liftA2 :: (a0 -> b -> c) -> Distinctspec a a0 -> Distinctspec a b -> Distinctspec a c #

(*>) :: Distinctspec a a0 -> Distinctspec a b -> Distinctspec a b #

(<*) :: Distinctspec a a0 -> Distinctspec a b -> Distinctspec a a0 #

Deprecated

distinctOnCorrect :: Default Unpackspec b b => (a -> b) -> Select a -> Select a Source #

Use distinctOn instead. Will be deprecated in 0.10.

distinctOnByCorrect :: Default Unpackspec b b => (a -> b) -> Order a -> Select a -> Select a Source #

Use distinctOnBy instead. Will be deprecated in 0.10.