@@ -29,8 +29,8 @@ import Data.Maybe (fromMaybe)
2929data Expr a where
3030 Col :: Columnable a => T. Text -> Expr a
3131 Lit :: Columnable a => a -> Expr a
32- Apply :: (Columnable a , ColumnifyRep ( KindOf a ) a , Columnable b , ColumnifyRep ( KindOf b ) b ) => (b -> a ) -> Expr b -> Expr a
33- BinOp :: (Columnable c , ColumnifyRep ( KindOf c ) c , Columnable b , ColumnifyRep ( KindOf b ) b , Columnable a , ColumnifyRep ( KindOf a ) a ) => (c -> b -> a ) -> Expr c -> Expr b -> Expr a
32+ Apply :: (Columnable a , Columnable b ) => (b -> a ) -> Expr b -> Expr a
33+ BinOp :: (Columnable c , Columnable b , Columnable a ) => (c -> b -> a ) -> Expr c -> Expr b -> Expr a
3434
3535interpret :: forall a b . (Columnable a ) => DataFrame -> Expr a -> TypedColumn a
3636interpret df (Lit value) = TColumn $ toColumn' $ V. replicate (fst $ dataframeDimensions df) value
@@ -45,7 +45,7 @@ interpret df (BinOp (f :: c -> d -> e) left right) = let
4545 (TColumn right') = interpret @ d df right
4646 in TColumn $ zipWithColumns f left' right'
4747
48- instance (Num a , Columnable a , ColumnifyRep ( KindOf a ) a ) => Num (Expr a ) where
48+ instance (Num a , Columnable a ) => Num (Expr a ) where
4949 (+) :: Expr a -> Expr a -> Expr a
5050 (+) = BinOp (+)
5151
@@ -64,14 +64,14 @@ instance (Num a, Columnable a, ColumnifyRep (KindOf a) a) => Num (Expr a) where
6464 signum :: Num a => Expr a -> Expr a
6565 signum = Apply signum
6666
67- instance (Fractional a , Columnable a , ColumnifyRep ( KindOf a ) a ) => Fractional (Expr a ) where
67+ instance (Fractional a , Columnable a ) => Fractional (Expr a ) where
6868 fromRational :: (Fractional a , Columnable a ) => Rational -> Expr a
6969 fromRational = Lit . fromRational
7070
7171 (/) :: (Fractional a , Columnable a ) => Expr a -> Expr a -> Expr a
7272 (/) = BinOp (/)
7373
74- instance (Floating a , Columnable a , ColumnifyRep ( KindOf a ) a ) => Floating (Expr a ) where
74+ instance (Floating a , Columnable a ) => Floating (Expr a ) where
7575 pi :: (Floating a , Columnable a ) => Expr a
7676 pi = Lit pi
7777 exp :: (Floating a , Columnable a ) => Expr a -> Expr a
@@ -107,14 +107,29 @@ instance (Show a) => Show (Expr a) where
107107 show (Apply f value) = " apply(" ++ show value ++ " )"
108108 show (BinOp f a b) = " binop(" ++ show a ++ " , " ++ show b ++ " )"
109109
110- col :: ( Columnable a , ColumnifyRep ( KindOf a ) a ) => T. Text -> Expr a
110+ col :: Columnable a => T. Text -> Expr a
111111col = Col
112112
113- lit :: ( Columnable a , ColumnifyRep ( KindOf a ) a ) => a -> Expr a
113+ lit :: Columnable a => a -> Expr a
114114lit = Lit
115115
116- lift :: (Columnable a , ColumnifyRep ( KindOf a ) a , Columnable b , ColumnifyRep ( KindOf b ) b ) => (a -> b ) -> Expr a -> Expr b
116+ lift :: (Columnable a , Columnable b ) => (a -> b ) -> Expr a -> Expr b
117117lift = Apply
118118
119- lift2 :: (ColumnifyRep ( KindOf c ) c , Columnable c , ColumnifyRep ( KindOf b ) b , Columnable b , ColumnifyRep ( KindOf a ) a , Columnable a ) => (c -> b -> a ) -> Expr c -> Expr b -> Expr a
119+ lift2 :: (Columnable c , Columnable b , Columnable a ) => (c -> b -> a ) -> Expr c -> Expr b -> Expr a
120120lift2 = BinOp
121+
122+ eq :: (Columnable a , Eq a ) => Expr a -> Expr a -> Expr Bool
123+ eq = BinOp (==)
124+
125+ lt :: (Columnable a , Ord a ) => Expr a -> Expr a -> Expr Bool
126+ lt = BinOp (<)
127+
128+ gt :: (Columnable a , Ord a ) => Expr a -> Expr a -> Expr Bool
129+ gt = BinOp (<)
130+
131+ leq :: (Columnable a , Ord a , Eq a ) => Expr a -> Expr a -> Expr Bool
132+ leq = BinOp (<=)
133+
134+ geq :: (Columnable a , Ord a , Eq a ) => Expr a -> Expr a -> Expr Bool
135+ geq = BinOp (<=)
0 commit comments