Skip to content

Commit

Permalink
Add Rel8.Tabulate, a complementary API for writing queries
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-circuithub committed Jul 14, 2021
1 parent b44ea81 commit 40f9758
Show file tree
Hide file tree
Showing 3 changed files with 625 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rel8.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ library
build-depends:
aeson
, base ^>= 4.14 || ^>=4.15
, bifunctors
, bytestring
, case-insensitive
, comonad
, contravariant
, hasql ^>= 1.4.5.1
, opaleye ^>= 0.7.3.0
, profunctors
, product-profunctors
, scientific
, semialign
, semigroupoids
Expand All @@ -51,6 +53,7 @@ library
Rel8.Expr.Num
Rel8.Expr.Text
Rel8.Expr.Time
Rel8.Tabulate

other-modules:
Rel8.Aggregate
Expand Down
6 changes: 6 additions & 0 deletions src/Rel8/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ import qualified Opaleye.Internal.Tag as Opaleye
import Rel8.Query.Set ( unionAll )
import Rel8.Query.Opaleye ( fromOpaleye )
import Rel8.Query.Values ( values )
import Rel8.Table ( fromColumns, toColumns )
import Rel8.Table.Alternative
( AltTable, (<|>:)
, AlternativeTable, emptyTable
)
import Rel8.Table.Projection ( Projectable, apply, project )

-- semigroupoids
import Data.Functor.Apply ( Apply, (<.>) )
Expand Down Expand Up @@ -151,6 +153,10 @@ newtype Query a =
)


instance Projectable Query where
project f = fmap (fromColumns . apply f . toColumns)


instance Functor Query where
fmap f (Query a) = Query (fmap (fmap (fmap f)) a)

Expand Down
Loading

0 comments on commit 40f9758

Please sign in to comment.