| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
DataFrame.Typed.Expr
Contents
- Core typed expression type (re-exported from Types)
- Column reference (schema-checked)
- Literals
- Conditional
- Unary / binary lifting
- Same-type comparison operators
- Same-type arithmetic operators
- Same-type exponentiation operators
- Nullable-aware arithmetic operators
- Nullable-aware exponentiation operators
- Nullable-aware comparison operators (three-valued logic)
- Logical operators
- Aggregation combinators
- Cast / coercion expressions
- Sort helpers
- Additional expression functions
- Orphan instances
Description
Type-safe expression construction for typed DataFrames.
Unlike the untyped Expr a where column references are unchecked strings,
TExpr ensures at compile time that:
- Referenced columns exist in the schema
- Column types match the expression type
Example
type Schema = '[ '("age", Int), '("salary", Double)]
-- This compiles:
goodExpr :: TExpr Schema Double
goodExpr = col @"salary"
-- This gives a compile-time error (column not found):
badExpr :: TExpr Schema Double
badExpr = col @"nonexistent"
-- This gives a compile-time error (type mismatch):
wrongType :: TExpr Schema Int
wrongType = col @"salary" -- salary is Double, not Int
Synopsis
- newtype TExpr (cols :: [(Symbol, Type)]) a = TExpr {}
- col :: forall (name :: Symbol) (cols :: [(Symbol, Type)]) a. (KnownSymbol name, a ~ SafeLookup name cols, Columnable a, AssertPresent name cols) => TExpr cols a
- lit :: forall a (cols :: [(Symbol, Type)]). Columnable a => a -> TExpr cols a
- ifThenElse :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols Bool -> TExpr cols a -> TExpr cols a -> TExpr cols a
- lift :: forall a b (cols :: [(Symbol, Type)]). (Columnable a, Columnable b) => (a -> b) -> TExpr cols a -> TExpr cols b
- lift2 :: forall a b c (cols :: [(Symbol, Type)]). (Columnable a, Columnable b, Columnable c) => (a -> b -> c) -> TExpr cols a -> TExpr cols b -> TExpr cols c
- nullLift :: forall a r (cols :: [(Symbol, Type)]). (NullLift1Op a r (NullLift1Result a r), Columnable (NullLift1Result a r)) => (BaseType a -> r) -> TExpr cols a -> TExpr cols (NullLift1Result a r)
- nullLift2 :: forall a b r (cols :: [(Symbol, Type)]). (NullLift2Op a b r (NullLift2Result a b r), Columnable (NullLift2Result a b r)) => (BaseType a -> BaseType b -> r) -> TExpr cols a -> TExpr cols b -> TExpr cols (NullLift2Result a b r)
- (.==.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Eq a) => TExpr cols a -> TExpr cols a -> TExpr cols Bool
- (./=.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Eq a) => TExpr cols a -> TExpr cols a -> TExpr cols Bool
- (.<.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Ord a) => TExpr cols a -> TExpr cols a -> TExpr cols Bool
- (.<=.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Ord a) => TExpr cols a -> TExpr cols a -> TExpr cols Bool
- (.>=.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Ord a) => TExpr cols a -> TExpr cols a -> TExpr cols Bool
- (.>.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Ord a) => TExpr cols a -> TExpr cols a -> TExpr cols Bool
- (.+.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Num a) => TExpr cols a -> TExpr cols a -> TExpr cols a
- (.-.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Num a) => TExpr cols a -> TExpr cols a -> TExpr cols a
- (.*.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Num a) => TExpr cols a -> TExpr cols a -> TExpr cols a
- (./.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Fractional a) => TExpr cols a -> TExpr cols a -> TExpr cols a
- (.^^.) :: forall a b (cols :: [(Symbol, Type)]). (Columnable a, Columnable b, Fractional a, Integral b) => TExpr cols a -> TExpr cols b -> TExpr cols a
- (.^.) :: forall a b (cols :: [(Symbol, Type)]). (Columnable a, Columnable b, Num a, Integral b) => TExpr cols a -> TExpr cols b -> TExpr cols a
- (.+) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b (Promote (BaseType a) (BaseType b)) (WidenResult a b), Num (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (WidenResult a b)
- (.-) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b (Promote (BaseType a) (BaseType b)) (WidenResult a b), Num (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (WidenResult a b)
- (.*) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b (Promote (BaseType a) (BaseType b)) (WidenResult a b), Num (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (WidenResult a b)
- (./) :: forall a b (cols :: [(Symbol, Type)]). (DivWidenOp (BaseType a) (BaseType b), NullLift2Op a b (PromoteDiv (BaseType a) (BaseType b)) (WidenResultDiv a b), Fractional (PromoteDiv (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (WidenResultDiv a b)
- (.^^) :: forall a b (cols :: [(Symbol, Type)]). (Columnable (BaseType a), Columnable (BaseType b), Fractional (BaseType a), Integral (BaseType b), NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b (BaseType a) a, Num (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols a
- (.^) :: forall a b (cols :: [(Symbol, Type)]). (Columnable (BaseType a), Columnable (BaseType b), Num (BaseType a), Integral (BaseType b), NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b (BaseType a) a, Num (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols a
- (.==) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b Bool (NullCmpResult a b), Eq (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (NullCmpResult a b)
- (./=) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b Bool (NullCmpResult a b), Eq (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (NullCmpResult a b)
- (.<) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b Bool (NullCmpResult a b), Ord (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (NullCmpResult a b)
- (.<=) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b Bool (NullCmpResult a b), Ord (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (NullCmpResult a b)
- (.>=) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b Bool (NullCmpResult a b), Ord (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (NullCmpResult a b)
- (.>) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b Bool (NullCmpResult a b), Ord (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (NullCmpResult a b)
- (.&&.) :: forall (cols :: [(Symbol, Type)]). TExpr cols Bool -> TExpr cols Bool -> TExpr cols Bool
- (.||.) :: forall (cols :: [(Symbol, Type)]). TExpr cols Bool -> TExpr cols Bool -> TExpr cols Bool
- (.&&) :: forall a b (cols :: [(Symbol, Type)]). (NullableCmpOp a b (NullCmpResult a b), BaseType a ~ Bool) => TExpr cols a -> TExpr cols b -> TExpr cols (NullCmpResult a b)
- (.||) :: forall a b (cols :: [(Symbol, Type)]). (NullableCmpOp a b (NullCmpResult a b), BaseType a ~ Bool) => TExpr cols a -> TExpr cols b -> TExpr cols (NullCmpResult a b)
- not :: forall (cols :: [(Symbol, Type)]). TExpr cols Bool -> TExpr cols Bool
- sum :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Num a) => TExpr cols a -> TExpr cols a
- mean :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Real a) => TExpr cols a -> TExpr cols Double
- median :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Real a, Unbox a) => TExpr cols a -> TExpr cols Double
- count :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> TExpr cols Int
- countAll :: forall (cols :: [(Symbol, Type)]). TExpr cols Int
- minimum :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Ord a) => TExpr cols a -> TExpr cols a
- maximum :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Ord a) => TExpr cols a -> TExpr cols a
- collect :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> TExpr cols [a]
- over :: forall (names :: [Symbol]) (cols :: [(Symbol, Type)]) a. (Columnable a, AllKnownSymbol names, AssertAllPresent names cols) => TExpr cols a -> TExpr cols a
- castExpr :: forall b (cols :: [(Symbol, Type)]) src. (Columnable b, Columnable src, Read b) => TExpr cols src -> TExpr cols (Maybe b)
- castExprWithDefault :: forall b (cols :: [(Symbol, Type)]) src. (Columnable b, Columnable src, Read b) => b -> TExpr cols src -> TExpr cols b
- castExprEither :: forall b (cols :: [(Symbol, Type)]) src. (Columnable b, Columnable src, Read b) => TExpr cols src -> TExpr cols (Either Text b)
- unsafeCastExpr :: forall b (cols :: [(Symbol, Type)]) src. (Columnable b, Columnable src, Read b) => TExpr cols src -> TExpr cols b
- toDouble :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Real a) => TExpr cols a -> TExpr cols Double
- asc :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Ord a) => TExpr cols a -> TSortOrder cols
- desc :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Ord a) => TExpr cols a -> TSortOrder cols
- module DataFrame.Typed.Expr.Extra
Core typed expression type (re-exported from Types)
newtype TExpr (cols :: [(Symbol, Type)]) a #
A typed expression validated against schema cols, producing values of type a.
Unlike the untyped 'Expr a', a TExpr can only be constructed through
type-safe combinators (col, lit, arithmetic operations) that verify
column references exist in the schema with the correct type.
Use unTExpr to extract the underlying Expr for delegation to the untyped API.
Instances
| (KnownSymbol name, a ~ SafeLookup name cols, Columnable a, AssertPresent name cols) => IsLabel name (TExpr cols a) Source # | Use a column name as an adults = filterWhere (#age .>=. lit 18) people |
Defined in DataFrame.Typed.Expr | |
| (IsString a, Columnable a) => IsString (TExpr cols a) Source # | |
Defined in DataFrame.Typed.Expr Methods fromString :: String -> TExpr cols a # | |
| (Floating a, Columnable a) => Floating (TExpr cols a) Source # | |
Defined in DataFrame.Typed.Expr Methods exp :: TExpr cols a -> TExpr cols a # log :: TExpr cols a -> TExpr cols a # sqrt :: TExpr cols a -> TExpr cols a # (**) :: TExpr cols a -> TExpr cols a -> TExpr cols a # logBase :: TExpr cols a -> TExpr cols a -> TExpr cols a # sin :: TExpr cols a -> TExpr cols a # cos :: TExpr cols a -> TExpr cols a # tan :: TExpr cols a -> TExpr cols a # asin :: TExpr cols a -> TExpr cols a # acos :: TExpr cols a -> TExpr cols a # atan :: TExpr cols a -> TExpr cols a # sinh :: TExpr cols a -> TExpr cols a # cosh :: TExpr cols a -> TExpr cols a # tanh :: TExpr cols a -> TExpr cols a # asinh :: TExpr cols a -> TExpr cols a # acosh :: TExpr cols a -> TExpr cols a # atanh :: TExpr cols a -> TExpr cols a # log1p :: TExpr cols a -> TExpr cols a # expm1 :: TExpr cols a -> TExpr cols a # | |
| (Num a, Columnable a) => Num (TExpr cols a) Source # | |
Defined in DataFrame.Typed.Expr Methods (+) :: TExpr cols a -> TExpr cols a -> TExpr cols a # (-) :: TExpr cols a -> TExpr cols a -> TExpr cols a # (*) :: TExpr cols a -> TExpr cols a -> TExpr cols a # negate :: TExpr cols a -> TExpr cols a # abs :: TExpr cols a -> TExpr cols a # signum :: TExpr cols a -> TExpr cols a # fromInteger :: Integer -> TExpr cols a # | |
| (Fractional a, Columnable a) => Fractional (TExpr cols a) Source # | |
| Show a => Show (TExpr cols a) | Shows the underlying expression; the schema phantom is type-level only. |
Column reference (schema-checked)
col :: forall (name :: Symbol) (cols :: [(Symbol, Type)]) a. (KnownSymbol name, a ~ SafeLookup name cols, Columnable a, AssertPresent name cols) => TExpr cols a Source #
Create a typed column reference. This is the key type-safety entry point.
The column name must exist in cols and its type must match a.
Both checks happen at compile time via type families.
salary :: TExpr '[("salary", Double)] Double
salary = col @"salary"
Literals
lit :: forall a (cols :: [(Symbol, Type)]). Columnable a => a -> TExpr cols a Source #
Create a literal expression. Valid for any schema since it references no columns.
Conditional
ifThenElse :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols Bool -> TExpr cols a -> TExpr cols a -> TExpr cols a Source #
Conditional expression.
Unary / binary lifting
lift :: forall a b (cols :: [(Symbol, Type)]). (Columnable a, Columnable b) => (a -> b) -> TExpr cols a -> TExpr cols b Source #
Lift a unary function into a typed expression.
lift2 :: forall a b c (cols :: [(Symbol, Type)]). (Columnable a, Columnable b, Columnable c) => (a -> b -> c) -> TExpr cols a -> TExpr cols b -> TExpr cols c Source #
Lift a binary function into typed expressions.
nullLift :: forall a r (cols :: [(Symbol, Type)]). (NullLift1Op a r (NullLift1Result a r), Columnable (NullLift1Result a r)) => (BaseType a -> r) -> TExpr cols a -> TExpr cols (NullLift1Result a r) Source #
Typed nullLift: lift a unary function with nullable propagation.
When the input is Maybe a, Nothing short-circuits; when plain a, applies directly.
The return type is inferred via NullLift1Result: no annotation needed.
nullLift2 :: forall a b r (cols :: [(Symbol, Type)]). (NullLift2Op a b r (NullLift2Result a b r), Columnable (NullLift2Result a b r)) => (BaseType a -> BaseType b -> r) -> TExpr cols a -> TExpr cols b -> TExpr cols (NullLift2Result a b r) Source #
Typed nullLift2: lift a binary function with nullable propagation.
Any Nothing operand short-circuits to Nothing in the result.
The return type is inferred via NullLift2Result: no annotation needed.
Same-type comparison operators
(.==.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Eq a) => TExpr cols a -> TExpr cols a -> TExpr cols Bool infixl 4 Source #
(./=.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Eq a) => TExpr cols a -> TExpr cols a -> TExpr cols Bool infixl 4 Source #
(.<.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Ord a) => TExpr cols a -> TExpr cols a -> TExpr cols Bool infixl 4 Source #
(.<=.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Ord a) => TExpr cols a -> TExpr cols a -> TExpr cols Bool infixl 4 Source #
(.>=.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Ord a) => TExpr cols a -> TExpr cols a -> TExpr cols Bool infixl 4 Source #
(.>.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Ord a) => TExpr cols a -> TExpr cols a -> TExpr cols Bool infixl 4 Source #
Same-type arithmetic operators
(.+.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Num a) => TExpr cols a -> TExpr cols a -> TExpr cols a infixl 6 Source #
(.-.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Num a) => TExpr cols a -> TExpr cols a -> TExpr cols a infixl 6 Source #
(.*.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Num a) => TExpr cols a -> TExpr cols a -> TExpr cols a infixl 7 Source #
(./.) :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Fractional a) => TExpr cols a -> TExpr cols a -> TExpr cols a infixl 7 Source #
Same-type exponentiation operators
(.^^.) :: forall a b (cols :: [(Symbol, Type)]). (Columnable a, Columnable b, Fractional a, Integral b) => TExpr cols a -> TExpr cols b -> TExpr cols a infixr 8 Source #
(.^.) :: forall a b (cols :: [(Symbol, Type)]). (Columnable a, Columnable b, Num a, Integral b) => TExpr cols a -> TExpr cols b -> TExpr cols a infixr 8 Source #
Nullable-aware arithmetic operators
(.+) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b (Promote (BaseType a) (BaseType b)) (WidenResult a b), Num (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (WidenResult a b) infixl 6 Source #
Nullable-aware addition. Works for all combinations of nullable/non-nullable operands.
col @"x" .+ col @"y" -- :: TExpr cols (Maybe Int) when y :: Maybe Int
(.-) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b (Promote (BaseType a) (BaseType b)) (WidenResult a b), Num (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (WidenResult a b) infixl 6 Source #
Nullable-aware subtraction.
(.*) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b (Promote (BaseType a) (BaseType b)) (WidenResult a b), Num (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (WidenResult a b) infixl 7 Source #
Nullable-aware multiplication.
(./) :: forall a b (cols :: [(Symbol, Type)]). (DivWidenOp (BaseType a) (BaseType b), NullLift2Op a b (PromoteDiv (BaseType a) (BaseType b)) (WidenResultDiv a b), Fractional (PromoteDiv (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (WidenResultDiv a b) infixl 7 Source #
Nullable-aware division. Integral operands are promoted to Double.
Nullable-aware exponentiation operators
(.^^) :: forall a b (cols :: [(Symbol, Type)]). (Columnable (BaseType a), Columnable (BaseType b), Fractional (BaseType a), Integral (BaseType b), NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b (BaseType a) a, Num (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols a infixr 8 Source #
Nullable-aware exponentiation (fractional base, integral exponent).
(.^) :: forall a b (cols :: [(Symbol, Type)]). (Columnable (BaseType a), Columnable (BaseType b), Num (BaseType a), Integral (BaseType b), NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b (BaseType a) a, Num (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols a infixr 8 Source #
Nullable-aware exponentiation (num base, integral exponent).
Nullable-aware comparison operators (three-valued logic)
(.==) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b Bool (NullCmpResult a b), Eq (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (NullCmpResult a b) infix 4 Source #
Nullable-aware equality. Widens numeric operands to their common type,
so TExpr cols Double .== TExpr cols Int typechecks. Returns Maybe Bool
when either operand is nullable.
(./=) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b Bool (NullCmpResult a b), Eq (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (NullCmpResult a b) infix 4 Source #
Nullable-aware inequality. Widens numeric operands to their common type.
(.<) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b Bool (NullCmpResult a b), Ord (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (NullCmpResult a b) infix 4 Source #
Nullable-aware less-than. Widens numeric operands to their common type.
(.<=) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b Bool (NullCmpResult a b), Ord (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (NullCmpResult a b) infix 4 Source #
Nullable-aware less-than-or-equal. Widens numeric operands to their common type.
(.>=) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b Bool (NullCmpResult a b), Ord (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (NullCmpResult a b) infix 4 Source #
Nullable-aware greater-than-or-equal. Widens numeric operands to their common type.
(.>) :: forall a b (cols :: [(Symbol, Type)]). (NumericWidenOp (BaseType a) (BaseType b), NullLift2Op a b Bool (NullCmpResult a b), Ord (Promote (BaseType a) (BaseType b))) => TExpr cols a -> TExpr cols b -> TExpr cols (NullCmpResult a b) infix 4 Source #
Nullable-aware greater-than. Widens numeric operands to their common type.
Logical operators
(.&&.) :: forall (cols :: [(Symbol, Type)]). TExpr cols Bool -> TExpr cols Bool -> TExpr cols Bool infixr 3 Source #
(.||.) :: forall (cols :: [(Symbol, Type)]). TExpr cols Bool -> TExpr cols Bool -> TExpr cols Bool infixr 2 Source #
(.&&) :: forall a b (cols :: [(Symbol, Type)]). (NullableCmpOp a b (NullCmpResult a b), BaseType a ~ Bool) => TExpr cols a -> TExpr cols b -> TExpr cols (NullCmpResult a b) infixr 3 Source #
Nullable-aware logical AND. Returns Maybe Bool when either operand is nullable.
(.||) :: forall a b (cols :: [(Symbol, Type)]). (NullableCmpOp a b (NullCmpResult a b), BaseType a ~ Bool) => TExpr cols a -> TExpr cols b -> TExpr cols (NullCmpResult a b) infixr 2 Source #
Nullable-aware logical OR. Returns Maybe Bool when either operand is nullable.
Aggregation combinators
sum :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Num a) => TExpr cols a -> TExpr cols a Source #
mean :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Real a) => TExpr cols a -> TExpr cols Double Source #
median :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Real a, Unbox a) => TExpr cols a -> TExpr cols Double Source #
count :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> TExpr cols Int Source #
countAll :: forall (cols :: [(Symbol, Type)]). TExpr cols Int Source #
Row count, the equivalent of SQL's COUNT(*).
minimum :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Ord a) => TExpr cols a -> TExpr cols a Source #
maximum :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Ord a) => TExpr cols a -> TExpr cols a Source #
collect :: forall a (cols :: [(Symbol, Type)]). Columnable a => TExpr cols a -> TExpr cols [a] Source #
over :: forall (names :: [Symbol]) (cols :: [(Symbol, Type)]) a. (Columnable a, AllKnownSymbol names, AssertAllPresent names cols) => TExpr cols a -> TExpr cols a Source #
Cast / coercion expressions
castExpr :: forall b (cols :: [(Symbol, Type)]) src. (Columnable b, Columnable src, Read b) => TExpr cols src -> TExpr cols (Maybe b) Source #
castExprWithDefault :: forall b (cols :: [(Symbol, Type)]) src. (Columnable b, Columnable src, Read b) => b -> TExpr cols src -> TExpr cols b Source #
castExprEither :: forall b (cols :: [(Symbol, Type)]) src. (Columnable b, Columnable src, Read b) => TExpr cols src -> TExpr cols (Either Text b) Source #
unsafeCastExpr :: forall b (cols :: [(Symbol, Type)]) src. (Columnable b, Columnable src, Read b) => TExpr cols src -> TExpr cols b Source #
toDouble :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Real a) => TExpr cols a -> TExpr cols Double Source #
Sort helpers
asc :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Ord a) => TExpr cols a -> TSortOrder cols Source #
Create an ascending sort order from a typed expression.
desc :: forall a (cols :: [(Symbol, Type)]). (Columnable a, Ord a) => TExpr cols a -> TSortOrder cols Source #
Create a descending sort order from a typed expression.
Additional expression functions
module DataFrame.Typed.Expr.Extra
Orphan instances
| (KnownSymbol name, a ~ SafeLookup name cols, Columnable a, AssertPresent name cols) => IsLabel name (TExpr cols a) Source # | Use a column name as an adults = filterWhere (#age .>=. lit 18) people |
| (IsString a, Columnable a) => IsString (TExpr cols a) Source # | |
Methods fromString :: String -> TExpr cols a # | |
| (Floating a, Columnable a) => Floating (TExpr cols a) Source # | |
Methods exp :: TExpr cols a -> TExpr cols a # log :: TExpr cols a -> TExpr cols a # sqrt :: TExpr cols a -> TExpr cols a # (**) :: TExpr cols a -> TExpr cols a -> TExpr cols a # logBase :: TExpr cols a -> TExpr cols a -> TExpr cols a # sin :: TExpr cols a -> TExpr cols a # cos :: TExpr cols a -> TExpr cols a # tan :: TExpr cols a -> TExpr cols a # asin :: TExpr cols a -> TExpr cols a # acos :: TExpr cols a -> TExpr cols a # atan :: TExpr cols a -> TExpr cols a # sinh :: TExpr cols a -> TExpr cols a # cosh :: TExpr cols a -> TExpr cols a # tanh :: TExpr cols a -> TExpr cols a # asinh :: TExpr cols a -> TExpr cols a # acosh :: TExpr cols a -> TExpr cols a # atanh :: TExpr cols a -> TExpr cols a # log1p :: TExpr cols a -> TExpr cols a # expm1 :: TExpr cols a -> TExpr cols a # | |
| (Num a, Columnable a) => Num (TExpr cols a) Source # | |
Methods (+) :: TExpr cols a -> TExpr cols a -> TExpr cols a # (-) :: TExpr cols a -> TExpr cols a -> TExpr cols a # (*) :: TExpr cols a -> TExpr cols a -> TExpr cols a # negate :: TExpr cols a -> TExpr cols a # abs :: TExpr cols a -> TExpr cols a # signum :: TExpr cols a -> TExpr cols a # fromInteger :: Integer -> TExpr cols a # | |
| (Fractional a, Columnable a) => Fractional (TExpr cols a) Source # | |