@@ -29,83 +29,83 @@ 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 , 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
32+ Apply :: (Columnable a , Columnable b ) => T. Text -> (b -> a ) -> Expr b -> Expr a
33+ BinOp :: (Columnable c , Columnable b , Columnable a ) => T. Text -> (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
3737interpret df (Col name) = case getColumn name df of
3838 Nothing -> throw $ ColumnNotFoundException name " " (map fst $ M. toList $ columnIndices df)
3939 Just col -> TColumn col
40- interpret df (Apply (f :: c -> d ) value) = let
40+ interpret df (Apply _ (f :: c -> d ) value) = let
4141 (TColumn value') = interpret @ c df value
4242 in TColumn $ fromMaybe (error " transform returned nothing" ) (transform f value')
43- interpret df (BinOp (f :: c -> d -> e ) left right) = let
43+ interpret df (BinOp _ (f :: c -> d -> e ) left right) = let
4444 (TColumn left') = interpret @ c df left
4545 (TColumn right') = interpret @ d df right
4646 in TColumn $ zipWithColumns f left' right'
4747
4848instance (Num a , Columnable a ) => Num (Expr a ) where
4949 (+) :: Expr a -> Expr a -> Expr a
50- (+) = BinOp (+)
50+ (+) = BinOp " add " (+)
5151
5252 (*) :: Expr a -> Expr a -> Expr a
53- (*) = BinOp (*)
53+ (*) = BinOp " mult " (*)
5454
5555 fromInteger :: Integer -> Expr a
5656 fromInteger = Lit . fromInteger
5757
5858 negate :: Expr a -> Expr a
59- negate = Apply negate
59+ negate = Apply " negate " negate
6060
6161 abs :: Num a => Expr a -> Expr a
62- abs = Apply abs
62+ abs = Apply " abs " abs
6363
6464 signum :: Num a => Expr a -> Expr a
65- signum = Apply signum
65+ signum = Apply " signum " signum
6666
6767instance (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
72- (/) = BinOp (/)
72+ (/) = BinOp " divide " (/)
7373
7474instance (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
78- exp = Apply exp
78+ exp = Apply " exp " exp
7979 log :: (Floating a , Columnable a ) => Expr a -> Expr a
80- log = Apply log
80+ log = Apply " log " log
8181 sin :: (Floating a , Columnable a ) => Expr a -> Expr a
82- sin = Apply sin
82+ sin = Apply " sin " sin
8383 cos :: (Floating a , Columnable a ) => Expr a -> Expr a
84- cos = Apply cos
84+ cos = Apply " cos " cos
8585 asin :: (Floating a , Columnable a ) => Expr a -> Expr a
86- asin = Apply asin
86+ asin = Apply " asin " asin
8787 acos :: (Floating a , Columnable a ) => Expr a -> Expr a
88- acos = Apply acos
88+ acos = Apply " acos " acos
8989 atan :: (Floating a , Columnable a ) => Expr a -> Expr a
90- atan = Apply atan
90+ atan = Apply " atan " atan
9191 sinh :: (Floating a , Columnable a ) => Expr a -> Expr a
92- sinh = Apply sinh
92+ sinh = Apply " sinh " sinh
9393 cosh :: (Floating a , Columnable a ) => Expr a -> Expr a
94- cosh = Apply cosh
94+ cosh = Apply " cosh " cosh
9595 asinh :: (Floating a , Columnable a ) => Expr a -> Expr a
96- asinh = Apply sinh
96+ asinh = Apply " asinh " sinh
9797 acosh :: (Floating a , Columnable a ) => Expr a -> Expr a
98- acosh = Apply acosh
98+ acosh = Apply " acosh " acosh
9999 atanh :: (Floating a , Columnable a ) => Expr a -> Expr a
100- atanh = Apply atanh
100+ atanh = Apply " atanh " atanh
101101
102102
103103instance (Show a ) => Show (Expr a ) where
104- show :: Show a => Expr a -> String
105- show (Col name) = " col(" ++ T. unpack name ++ " )"
104+ show :: forall a . Show a => Expr a -> String
105+ show (Col name) = " col@ " ++ show (typeRep @ a ) ++ " (" ++ T. unpack name ++ " )"
106106 show (Lit value) = show value
107- show (Apply f value) = " apply (" ++ show value ++ " )"
108- show (BinOp f a b) = " binop (" ++ show a ++ " , " ++ show b ++ " )"
107+ show (Apply name f value) = T. unpack name ++ " (" ++ show value ++ " )"
108+ show (BinOp name f a b) = T. unpack name ++ " (" ++ show a ++ " , " ++ show b ++ " )"
109109
110110col :: Columnable a => T. Text -> Expr a
111111col = Col
@@ -114,22 +114,22 @@ lit :: Columnable a => a -> Expr a
114114lit = Lit
115115
116116lift :: (Columnable a , Columnable b ) => (a -> b ) -> Expr a -> Expr b
117- lift = Apply
117+ lift = Apply " udf "
118118
119119lift2 :: (Columnable c , Columnable b , Columnable a ) => (c -> b -> a ) -> Expr c -> Expr b -> Expr a
120- lift2 = BinOp
120+ lift2 = BinOp " udf "
121121
122122eq :: (Columnable a , Eq a ) => Expr a -> Expr a -> Expr Bool
123- eq = BinOp (==)
123+ eq = BinOp " eq " (==)
124124
125125lt :: (Columnable a , Ord a ) => Expr a -> Expr a -> Expr Bool
126- lt = BinOp (<)
126+ lt = BinOp " lt " (<)
127127
128128gt :: (Columnable a , Ord a ) => Expr a -> Expr a -> Expr Bool
129- gt = BinOp (<)
129+ gt = BinOp " gt " (<)
130130
131131leq :: (Columnable a , Ord a , Eq a ) => Expr a -> Expr a -> Expr Bool
132- leq = BinOp (<=)
132+ leq = BinOp " leq " (<=)
133133
134134geq :: (Columnable a , Ord a , Eq a ) => Expr a -> Expr a -> Expr Bool
135- geq = BinOp (<=)
135+ geq = BinOp " geq " (<=)
0 commit comments