-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A tool for CSV files data querying from the shell with short queries. -- -- lsql-csv is a tool for small CSV file data querying from a shell with -- short queries. It makes it possible to work with small CSV files like -- with a read-only relational databases. The tool implements a new -- language LSQL similar to SQL, specifically designed for working with -- CSV files in shell. @package lsql-csv @version 0.1.0.2 -- | This module contains the definition of Lsql datatypes, their classes, -- and types Table and Column and functions over them for -- manipulation of them. module Lsql.Csv.Core.Tables -- | A single table of data data Table Table :: [String] -> [Column] -> Table -- | Single column of table data Column Column :: [String] -> [Value] -> Column -- | Representation of data in tables data Value IntValue :: Int -> Value StringValue :: String -> Value DoubleValue :: Double -> Value BoolValue :: Bool -> Value -- | Makes table out of rows of Value buildTable :: [String] -> [[String]] -> [[Value]] -> Table -- | Cross joins two tables into one. crossJoinTable :: Table -> Table -> Table -- | Filters out rows, where Column is false. The rows, where Column is -- true, are kept. filterTable :: Column -> Table -> Table -- | Sorts the table according to the given columns. sortTable :: [Column] -> Table -> Table -- | Splits the table into multiple tables so that rows of columns at first -- argument are at each table the same and number of tables is minimal. -- (factorization) byTable :: [Column] -> Table -> [Table] -- | Returns table with same metadata as original table, but no data (no -- rows). emptyTable :: Table -> Table -- | Returns pairs of names of Column and Column itself of -- the table columnNames :: Table -> [([String], Column)] -- | Returns all values of the Column columnValue :: Column -> [Value] -- | Converts column to list of string from its data showColumn :: Column -> [String] -- | Function for applying single argument function to Column applyOp :: (Value -> Value) -> Column -> Column -- | Function for applying two argument function to two Columns applyInOp :: (Value -> Value -> Value) -> Column -> Column -> Column -- | Class for converting a value to Bool class Boolable a getBool :: Boolable a => a -> Bool instance GHC.Show.Show Lsql.Csv.Core.Tables.Table instance GHC.Classes.Eq Lsql.Csv.Core.Tables.Column instance GHC.Classes.Ord Lsql.Csv.Core.Tables.Column instance GHC.Show.Show Lsql.Csv.Core.Tables.Column instance Lsql.Csv.Core.Tables.Boolable Lsql.Csv.Core.Tables.Value instance GHC.Classes.Ord Lsql.Csv.Core.Tables.Value instance GHC.Classes.Eq Lsql.Csv.Core.Tables.Value instance GHC.Real.Real Lsql.Csv.Core.Tables.Value instance GHC.Real.RealFrac Lsql.Csv.Core.Tables.Value instance GHC.Enum.Enum Lsql.Csv.Core.Tables.Value instance GHC.Real.Integral Lsql.Csv.Core.Tables.Value instance GHC.Num.Num Lsql.Csv.Core.Tables.Value instance GHC.Real.Fractional Lsql.Csv.Core.Tables.Value instance GHC.Float.Floating Lsql.Csv.Core.Tables.Value instance GHC.Show.Show Lsql.Csv.Core.Tables.Value -- | This module contains the definition of Symbol, SymbolMap -- and helper functions. module Lsql.Csv.Core.Symbols -- | Data type for single named column (Symbol) data Symbol -- | Datatype containing Map for aliases of symbols and list of all -- tables data SymbolMap -- | Lookup for Symbol (NamedColumn) in SymbolMap (-->) :: SymbolMap -> String -> Symbol -- | Lookup for Symbol (NamedColumn) in SymbolMap returning -- Column (==>) :: SymbolMap -> String -> Column -- | Generates SymbolMap out of list of Table getSymbolMap :: [Table] -> SymbolMap -- | Returns list of name aliases of all columns symbolList :: SymbolMap -> [String] -- | Returns list of Tables out of SymbolMap getTables :: SymbolMap -> [Table] -- | This module contains the syntactic tree definition and helper -- functions for its evaluation. module Lsql.Csv.Core.Functions -- | Syntax tree element data Arg -- | Call of function Function :: Function -> Arg -- | Reference to a column Symbol :: String -> Arg -- | Constant Value :: Value -> Arg -- | Syntax tree element data Function -- | Arithmetic function AritmeticF :: AritmeticF -> Function -- | Aggregate function AggregateF :: AggregateF -> Function -- | Logical function LogicF :: LogicF -> Function -- | Syntax tree element data AritmeticF Sin :: Arg -> AritmeticF Cos :: Arg -> AritmeticF Tan :: Arg -> AritmeticF Asin :: Arg -> AritmeticF Acos :: Arg -> AritmeticF Atan :: Arg -> AritmeticF Sinh :: Arg -> AritmeticF Cosh :: Arg -> AritmeticF Tanh :: Arg -> AritmeticF Asinh :: Arg -> AritmeticF Acosh :: Arg -> AritmeticF Atanh :: Arg -> AritmeticF Exp :: Arg -> AritmeticF Sqrt :: Arg -> AritmeticF Size :: Arg -> AritmeticF ToString :: Arg -> AritmeticF Append :: Arg -> Arg -> AritmeticF Round :: Arg -> AritmeticF Truncate :: Arg -> AritmeticF Ceiling :: Arg -> AritmeticF Floor :: Arg -> AritmeticF MinusS :: Arg -> AritmeticF Abs :: Arg -> AritmeticF Signum :: Arg -> AritmeticF Negate :: Arg -> AritmeticF Plus :: Arg -> Arg -> AritmeticF Minus :: Arg -> Arg -> AritmeticF Multiply :: Arg -> Arg -> AritmeticF Divide :: Arg -> Arg -> AritmeticF Power :: Arg -> Arg -> AritmeticF Even :: Arg -> AritmeticF Odd :: Arg -> AritmeticF NaturalPower :: Arg -> Arg -> AritmeticF Div :: Arg -> Arg -> AritmeticF Quot :: Arg -> Arg -> AritmeticF Rem :: Arg -> Arg -> AritmeticF Mod :: Arg -> Arg -> AritmeticF Gcd :: Arg -> Arg -> AritmeticF Lcm :: Arg -> Arg -> AritmeticF Less :: Arg -> Arg -> AritmeticF LessOrEqual :: Arg -> Arg -> AritmeticF More :: Arg -> Arg -> AritmeticF MoreOrEqual :: Arg -> Arg -> AritmeticF Equal :: Arg -> Arg -> AritmeticF NotEqual :: Arg -> Arg -> AritmeticF LeftOuterJoin :: Arg -> Arg -> AritmeticF In :: Arg -> Arg -> AritmeticF -- | Syntax tree element data LogicF And :: Arg -> Arg -> LogicF Or :: Arg -> Arg -> LogicF Not :: Arg -> LogicF -- | Syntax tree element data AggregateF Cat :: [Arg] -> AggregateF Sum :: [Arg] -> AggregateF Avg :: [Arg] -> AggregateF Count :: [Arg] -> AggregateF Min :: [Arg] -> AggregateF Max :: [Arg] -> AggregateF -- | Data type for single Column or single Arg data Printable ColumnP :: Column -> Printable ValueP :: Value -> Printable -- | Converts list of Printable to list of String columns -- Useful for generating CSV output genStrCols :: [Printable] -> [[String]] -- | Converts list of Printable to list of Column getCols :: [Printable] -> [Column] -- | Converts list of Printable to a Table getTable :: [String] -> [Printable] -> Table -- | Converts table to list of ColumnP Printables printTable :: Table -> [Printable] -- | Unions multiple first lines of lists of [Printable] into one -- Printable unionAggCols :: [[Printable]] -> [Printable] -- | Appends two arguments together appendArg :: Arg -> Arg -> Arg -- | Appends list of arguments together catterate :: [Arg] -> Arg -- | Evaluates all nonagregate functions to Printable. Fails on -- aggregate function. eval :: SymbolMap -> Arg -> Printable -- | Evaluates all aggregate functions. Normal functions are not evaluated -- if not called under other aggregate function. evalAggregateFunctions :: SymbolMap -> Arg -> Arg -- | Runs through the syntactic tree and check, whether it contains -- aggregate function. containsAggregateF :: Arg -> Bool instance GHC.Show.Show Lsql.Csv.Core.Functions.Printable instance GHC.Classes.Ord Lsql.Csv.Core.Functions.Printable instance GHC.Classes.Eq Lsql.Csv.Core.Functions.Printable -- | This module contains the Block definition and functions for -- getting specific types of blocks from the list of Block. module Lsql.Csv.Core.BlockOps -- | This data structure represents parsed blocks data Block Select :: [Arg] -> Block If :: Arg -> Block Sort :: [Arg] -> Block By :: [Arg] -> Block -- | Returns all selects blocks getSelects :: [Block] -> [[Arg]] -- | Makes conjunction of all if blocks (if none, simple True is returned) -- and returns it getIf :: [Block] -> Arg -- | Finds sort block, if exists, and returns it. If there is non, [] is -- returned. If there is more than one sort block, fails. getSort :: [Block] -> [Arg] -- | Finds by block, if exists, and returns it. If there is non, [] is -- returned. If there is more than one by block, fails. getBy :: [Block] -> [Arg] -- | This module contains the evaluator of lsql-csv program. module Lsql.Csv.Core.Evaluator -- | Evaluates the program in parsed [Block] over the input in -- SymbolMap evaluate :: SymbolMap -> [Block] -> [Printable] -- | This module contains a preprocessor parser, which splits the command -- into a list of strings - one string per one block. module Lsql.Csv.Lang.BlockSeparator -- | Preprocessor parser function, which splits command into list of -- strings - one string per one block. splitBlocks :: String -> [String] -- | This module implements a common Option type and its parsers for -- from blocks and command line optional arguments. module Lsql.Csv.Lang.Options -- | Option parser monad for parsing from block and command line optional -- arguments. optionParser :: Parser Option -- | Option datatype for representing from block and command line optional -- arguments. data Option Delimiter :: Char -> Option SecondaryDelimiter :: Char -> Option Quote :: Char -> Option Named :: Bool -> Option -- | A module for command line argument parsing. module Lsql.Csv.Lang.Args -- | A data type representing all arguments for one run of lsql-csv data Program Program :: String -> Char -> Char -> Bool -> Program -- | Parses given arguments to Program representation parseArgs :: [String] -> Program -- | Loads additional options to the Program reloadOpts :: Program -> [Option] -> Program instance GHC.Show.Show Lsql.Csv.Lang.Args.Program -- | This module contains curly bracket (braces) expansion implementation. module Lsql.Csv.Utils.BracketExpansion -- | Curly brackets (braces) expand function -- -- Argument is a String, which you want to expand. Returns a list -- of expanded Strings. -- -- There are given few usage examples: -- --
-- >>> bracketExpand "car{A,B}"
-- ["carA","carB"]
--
--
--
-- >>> bracketExpand "car{1..5}"
-- ["car1","car2","car3","car4","car5"]
--
--
--
-- >>> bracketExpand "{car,bus}{0..2}"
-- ["car0","car1","car2","bus0","bus1","bus2"]
--
bracketExpand :: String -> [String]
-- | This module implements selector expression and arithmetic expression
-- parsers.
module Lsql.Csv.Lang.Selector
-- | Selector expression parser.
selectorP :: [String] -> Parser [Arg]
-- | Arithmetic expression parser.
arithmeticExprP :: [String] -> Parser Arg
-- | This module contains a main parser of blocks other then the from
-- block.
module Lsql.Csv.Lang.BlockChain
-- | Function for parsing blocks
parseBlocks :: [String] -> [String] -> [Block]
-- | This module contains the CsvParser called by parseFile, which loads
-- input CSV files.
module Lsql.Csv.Lang.From.CsvParser
-- | Data structure representing one input file
data Assignment
-- | Input file without any assign names
CoreCsv :: Int -> String -> Program -> [Option] -> Assignment
-- | Input file with assign name
NamedCsv :: String -> Assignment -> Assignment
-- | Parses CSV file described in given Assignment
parseFile :: Assignment -> IO Table
-- | This module contains the from block parser. It loads the initial
-- SymbolMap.
module Lsql.Csv.Lang.From.Block
-- | Loads SymbolMap according to Program and from block
-- String in second argument.
getFromSymbols :: Program -> String -> IO SymbolMap
-- | This module contains CSV generator for the output.
module Lsql.Csv.Utils.CsvGenerator
-- | This function generates CSV output
csvGenerate :: Char -> Char -> [Printable] -> String
-- | This module contains the starting point for lsql-csv evaluation.
module Lsql.Csv.Main
-- | A starting point for lsql-csv evaluation. Returns String with output
-- CSV.
run :: Program -> IO String