lsql-csv-0.1.0.5: 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 #

A syntax tree element

Constructors

Function Function

A call of function

Symbol String

A reference to a column

Value Value

A constant

data Function Source #

A syntax tree element

Constructors

AritmeticF AritmeticF

An arithmetic function

AggregateF AggregateF

An aggregate function

LogicF LogicF

A logical function

data LogicF Source #

A syntax tree element

Constructors

And Arg Arg 
Or Arg Arg 
Not Arg 

data AggregateF Source #

A syntax tree element

Constructors

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

data Printable Source #

A data type for a single Column or a single Arg

Constructors

ColumnP Column 
ValueP Value 

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

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

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

Converts a list of Printable to a list of Column.

getTable Source #

Arguments

:: [String]

The names of the table

-> [Printable]

The columns of the table

-> Table 

Converts a list of Printable to a Table.

printTable :: Table -> [Printable] Source #

Converts a Table to a 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 a list of arguments together.

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

Evaluates all nonagregate functions to Printable. Fails on an 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 checks, whether it contains an aggregate function.