module Database.Ferry.Algebra.Monadic.Create (attachM, castM, eqJoinM, eqTJoinM, rankM, differenceM, rowrankM, posSelectM, selectM,
distinctM, crossM, notM, unionM, projM, aggrM, rownumM, rownum'M, operM, tagM) where
import qualified Database.Ferry.Algebra.Data.Create as C
import Database.Ferry.Algebra.Data.Algebra
import Database.Ferry.Algebra.Data.GraphBuilder
bind1 :: Monad m => (a -> m b) -> m a -> m b
bind1 = (=<<)
bind2 :: Monad m => (a -> b -> m c) -> m a -> m b -> m c
bind2 f a b = do
a' <- a
b' <- b
f a' b'
attachM :: ResAttrName -> ATy -> AVal -> GraphM a AlgNode -> GraphM a AlgNode
attachM n t v = bind1 (C.attach n t v)
castM :: AttrName -> ResAttrName -> ATy -> GraphM a AlgNode -> GraphM a AlgNode
castM n r t = bind1 (C.cast n r t)
eqJoinM :: String -> String -> GraphM a AlgNode -> GraphM a AlgNode -> GraphM a AlgNode
eqJoinM n1 n2 = bind2 (C.eqJoin n1 n2)
eqTJoinM :: [(String, String)] -> ProjInf -> GraphM a AlgNode -> GraphM a AlgNode -> GraphM a AlgNode
eqTJoinM eqs projI = bind2 (C.eqTJoin eqs projI)
rankM :: ResAttrName -> SortInf -> GraphM a AlgNode -> GraphM a AlgNode
rankM res sort = bind1 (C.rank res sort)
differenceM :: GraphM a AlgNode -> GraphM a AlgNode -> GraphM a AlgNode
differenceM = bind2 C.difference
rowrankM :: ResAttrName -> SortInf -> GraphM a AlgNode -> GraphM a AlgNode
rowrankM res sort = bind1 (C.rowrank res sort)
posSelectM :: Int -> SortInf -> Maybe AttrName -> GraphM a AlgNode -> GraphM a AlgNode
posSelectM n sort part = bind1 (C.posSelect n sort part)
selectM :: SelAttrName -> GraphM a AlgNode -> GraphM a AlgNode
selectM sel = bind1 (C.select sel)
distinctM :: GraphM a AlgNode -> GraphM a AlgNode
distinctM = bind1 C.distinct
crossM :: GraphM a AlgNode -> GraphM a AlgNode -> GraphM a AlgNode
crossM = bind2 C.cross
notM :: AttrName -> AttrName -> GraphM a AlgNode -> GraphM a AlgNode
notM r n = bind1 (C.notC r n)
unionM :: GraphM a AlgNode -> GraphM a AlgNode -> GraphM a AlgNode
unionM = bind2 C.union
projM :: ProjInf -> GraphM a AlgNode -> GraphM a AlgNode
projM cols = bind1 (C.proj cols)
aggrM :: [(AggrType, ResAttrName, Maybe AttrName)] -> Maybe PartAttrName -> GraphM a AlgNode -> GraphM a AlgNode
aggrM aggrs part = bind1 (C.aggr aggrs part)
rownumM :: AttrName -> [AttrName] -> Maybe AttrName -> GraphM a AlgNode -> GraphM a AlgNode
rownumM res sort part = bind1 (C.rownum res sort part)
rownum'M :: AttrName -> [(AttrName, SortDir)] -> Maybe AttrName -> GraphM a AlgNode -> GraphM a AlgNode
rownum'M res sort part = bind1 (C.rownum' res sort part)
operM :: String -> ResAttrName -> LeftAttrName -> RightAttrName -> GraphM a AlgNode -> GraphM a AlgNode
operM o r la ra = bind1 (C.oper o r la ra)
tagM :: String -> GraphM a AlgNode -> GraphM a AlgNode
tagM s = bind1 (C.tag s)