lsql-csv-0.1.0.2: A tool for CSV files data querying from the shell with short queries.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Lsql.Csv.Core.Functions

Description

This module contains the syntactic tree definition and helper functions for its evaluation.

Synopsis

Documentation

data Arg Source #

Syntax tree element

Constructors

Function Function

Call of function

Symbol String

Reference to a column

Value Value

Constant

data Function Source #

Syntax tree element

Constructors

AritmeticF AritmeticF

Arithmetic function

AggregateF AggregateF

Aggregate function

LogicF LogicF

Logical function

data LogicF Source #

Syntax tree element

Constructors

And Arg Arg 
Or Arg Arg 
Not Arg 

data AggregateF Source #

Syntax tree element

Constructors

Cat [Arg] 
Sum [Arg] 
Avg [Arg] 
Count [Arg] 
Min [Arg] 
Max [Arg] 

data Printable Source #

Data type for single Column or single Arg

Constructors

ColumnP Column 
ValueP Value 

genStrCols :: [Printable] -> [[String]] Source #

Converts list of Printable to list of String columns Useful for generating CSV output

getCols :: [Printable] -> [Column] Source #

Converts list of Printable to list of Column

getTable Source #

Arguments

:: [String]

Names of table

-> [Printable]

Columns of the table

-> Table 

Converts list of Printable to a Table

printTable :: Table -> [Printable] Source #

Converts table to list of ColumnP Printables

unionAggCols :: [[Printable]] -> [Printable] Source #

Unions multiple first lines of lists of [Printable] into one Printable

appendArg :: Arg -> Arg -> Arg Source #

Appends two arguments together

catterate :: [Arg] -> Arg Source #

Appends list of arguments together

eval :: SymbolMap -> Arg -> Printable Source #

Evaluates all nonagregate functions to Printable. Fails on aggregate function.

evalAggregateFunctions :: SymbolMap -> Arg -> Arg Source #

Evaluates all aggregate functions. Normal functions are not evaluated if not called under other aggregate function.

containsAggregateF :: Arg -> Bool Source #

Runs through the syntactic tree and check, whether it contains aggregate function.