-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b4cce9
commit e88ff0a
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{-# language FlexibleContexts #-} | ||
|
||
module Rel8.Query.Loop | ||
( loop | ||
) where | ||
|
||
-- base | ||
import Prelude | ||
|
||
-- opaleye | ||
import Opaleye.Lateral ( lateral ) | ||
import Opaleye.WithRecursive ( withRecursiveExplicit ) | ||
|
||
-- rel8 | ||
import Rel8.Expr ( Expr ) | ||
import Rel8.Query ( Query ) | ||
import Rel8.Query.Opaleye ( fromOpaleye, toOpaleye ) | ||
import Rel8.Table ( Table ) | ||
import Rel8.Table.Opaleye ( binaryspec ) | ||
|
||
|
||
loop :: Table Expr a => Query a -> (a -> Query a) -> Query a | ||
loop base recurse = | ||
fromOpaleye $ withRecursiveExplicit binaryspec base' recurse' | ||
where | ||
base' = toOpaleye base | ||
recurse' = lateral $ toOpaleye . recurse |