napkin-0.5.10
Copyright(c) Soostone Inc 2020
LicenseAllRightsReserved
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Napkin.Untyped.Ops

Description

 
Synopsis

Documentation

avg :: SExp -> SExp #

Basic aggregations

max :: SExp -> SExp #

min :: SExp -> SExp #

sum :: SExp -> SExp #

countd :: SExp -> SExp #

Distinct count of expression

nullary :: Ref Function -> SExp #

Function calls and common control flow

case_ :: [(SExp, SExp)] -> SExp -> SExp #

caseMatch_ #

Arguments

:: SExp

column to check

-> [(SExp, SExp)]

check equal on left assume right

-> SExp

default

-> SExp 

if_ :: SExp -> SExp -> SExp -> SExp #

sign :: SExp -> SExp #

Basic arithmetic

(/.) :: SExp -> SExp -> SExp #

cast :: SExp -> Type -> SExp #

Type casts

(==.) :: SExp -> SExp -> SExp infix 4 #

Logical operators

(/=.) :: SExp -> SExp -> SExp infix 4 #

(>=.) :: SExp -> SExp -> SExp infix 4 #

(>.) :: SExp -> SExp -> SExp infix 4 #

(<=.) :: SExp -> SExp -> SExp infix 4 #

(<.) :: SExp -> SExp -> SExp infix 4 #

is :: SExp -> SExp -> SExp #

isNot :: SExp -> SExp -> SExp #

in_ :: SExp -> [SExp] -> SExp #

notIn :: SExp -> [SExp] -> SExp #

any_ :: SExp -> SExp #

all_ :: SExp -> SExp #

not :: SExp -> SExp #

(.&&.) :: SExp -> SExp -> SExp infixr 3 #

(.||.) :: SExp -> SExp -> SExp infixr 2 #

and :: [SExp] -> SExp #

or :: [SExp] -> SExp #

maxOf :: SExp -> SExp -> SExp #

minOf :: SExp -> SExp -> SExp #

hardCount :: SExp #

Higher level combinators and utilities

sum 1

valueIf :: SExp -> SExp -> SExp -> SExp #

Replace exp if its equal to val with replace.

nullifyUnless :: SExp -> SExp -> SExp #

Set to null unless predicate is true

nullifyIf :: SExp -> SExp -> SExp #

Set to null if predicate is true

nullifyIfEmpty :: SExp -> SExp #

Make empty string NULL.

deepApply :: (SExp -> SExp) -> SExp -> SExp #

Apply a function on Lits and Vars, recursing deep into function calls, etc.

isEmpty :: SExp -> SExp #

Common case of a string column possibly being empty either by being a blank string or properly being NULL.

notEmpty :: SExp -> SExp #

Opposite of isEmpty

countTrue :: SExp -> SExp #

(Agg) Count number of Trues in a boolean expression.

boolToInt :: SExp -> SExp #

True -> 1, False -> 0

scopeGeneric :: [(Ref Function, SExp)] -> SExp -> SExp -> SExp #

TODO. This is may have holes; we need a principled end-to-end review of this transformation. Perhaps even put it as a primitive into the SExp type.

data BackendFunctionMeta #

Constructors

BackendFunctionMeta 

Fields

inferAggGeneric :: BackendFunctionMeta -> SExp -> AggLevel #

Infer aggregation level of an expression.

TODO: ExternRaw cant be inferred at the moment; needs more info inside the SExp if this becomes a problem.

unitBoundaryGeneric :: BackendFunctionMeta -> SExp -> [SExp] #

Explore expression's insides to pull out top level Unit expressions within its branches, but no deeper in each branch.

Originally created to help with common expression caching - since you can commonolize unit-level expressions without any side-effect.

Orphan instances

Fractional SExp # 
Instance details

Methods

(/) :: SExp -> SExp -> SExp #

recip :: SExp -> SExp #

fromRational :: Rational -> SExp #

Num SExp # 
Instance details

Methods

(+) :: SExp -> SExp -> SExp #

(-) :: SExp -> SExp -> SExp #

(*) :: SExp -> SExp -> SExp #

negate :: SExp -> SExp #

abs :: SExp -> SExp #

signum :: SExp -> SExp #

fromInteger :: Integer -> SExp #