module Rel8.Query.Opaleye
  ( fromOpaleye
  , toOpaleye
  , mapOpaleye
  , zipOpaleyeWith
  )
where

-- base
import Prelude

-- opaleye
import qualified Opaleye.Select as Opaleye

-- rel8
import {-# SOURCE #-} Rel8.Query ( Query( Query ) )


fromOpaleye :: Opaleye.Select a -> Query a
fromOpaleye :: Select a -> Query a
fromOpaleye = Select a -> Query a
forall a. Select a -> Query a
Query


toOpaleye :: Query a -> Opaleye.Select a
toOpaleye :: Query a -> Select a
toOpaleye (Query Select a
a) = Select a
a


mapOpaleye :: (Opaleye.Select a -> Opaleye.Select b) -> Query a -> Query b
mapOpaleye :: (Select a -> Select b) -> Query a -> Query b
mapOpaleye Select a -> Select b
f = Select b -> Query b
forall a. Select a -> Query a
fromOpaleye (Select b -> Query b)
-> (Query a -> Select b) -> Query a -> Query b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Select a -> Select b
f (Select a -> Select b)
-> (Query a -> Select a) -> Query a -> Select b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Query a -> Select a
forall a. Query a -> Select a
toOpaleye


zipOpaleyeWith :: ()
  => (Opaleye.Select a -> Opaleye.Select b -> Opaleye.Select c)
  -> Query a -> Query b -> Query c
zipOpaleyeWith :: (Select a -> Select b -> Select c) -> Query a -> Query b -> Query c
zipOpaleyeWith Select a -> Select b -> Select c
f Query a
a Query b
b = Select c -> Query c
forall a. Select a -> Query a
fromOpaleye (Select c -> Query c) -> Select c -> Query c
forall a b. (a -> b) -> a -> b
$ Select a -> Select b -> Select c
f (Query a -> Select a
forall a. Query a -> Select a
toOpaleye Query a
a) (Query b -> Select b
forall a. Query a -> Select a
toOpaleye Query b
b)