-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Data frames For working with tabular data files -- -- User-friendly, type safe, runtime efficient tooling for working with -- tabular data deserialized from comma-separated values (CSV) files. The -- type of each row of data is inferred from data, which can then be -- streamed from disk, or worked with in memory. @package Frames @version 0.2.1 -- | Helpers for working with type-level lists. module Frames.TypeLevel -- | Constraint that every element of a promoted list is equal to a -- particular type. That is, the list of types is a single type repeated -- some number of times. module Frames.ColumnTypeable data Parsed a Possibly :: a -> Parsed a Definitely :: a -> Parsed a -- | Values that can be read from a Text with more or less -- discrimination. class Parseable a where parse = fmap Definitely . fromText -- | Returns Nothing if a value of the given type can not be read; -- returns 'Just Possibly' if a value can be read, but is likely -- ambiguous (e.g. an empty string); returns 'Just Definitely' if a value -- can be read and is unlikely to be ambiguous." parse :: (Parseable a, MonadPlus m) => Text -> m (Parsed a) -- | Returns Nothing if a value of the given type can not be read; -- returns 'Just Possibly' if a value can be read, but is likely -- ambiguous (e.g. an empty string); returns 'Just Definitely' if a value -- can be read and is unlikely to be ambiguous." parse :: (Parseable a, Readable a, MonadPlus m) => Text -> m (Parsed a) -- | Discard any estimate of a parse's ambiguity. discardConfidence :: Parsed a -> a -- | Acts just like fromText: tries to parse a value from a -- Text and discards any estimate of the parse's ambiguity. parse' :: (MonadPlus m, Parseable a) => Text -> m a -- | This class relates a universe of possible column types to Haskell -- types, and provides a mechanism to infer which type best represents -- some textual data. class ColumnTypeable a colType :: ColumnTypeable a => a -> Q Type inferType :: ColumnTypeable a => Text -> a instance GHC.Show.Show a => GHC.Show.Show (Frames.ColumnTypeable.Parsed a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Frames.ColumnTypeable.Parsed a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Frames.ColumnTypeable.Parsed a) instance GHC.Base.Functor Frames.ColumnTypeable.Parsed instance Frames.ColumnTypeable.Parseable GHC.Types.Bool instance Frames.ColumnTypeable.Parseable GHC.Types.Int instance Frames.ColumnTypeable.Parseable GHC.Types.Float instance Frames.ColumnTypeable.Parseable GHC.Types.Double instance Frames.ColumnTypeable.Parseable Data.Text.Internal.Text -- | Column types module Frames.Col -- | A column's type includes a textual name and the data type of each -- element. newtype (:->) (s :: Symbol) a Col :: a -> (:->) a [getCol] :: (:->) a -> a -- | Used only for a show instance that parenthesizes the value. newtype Col' s a Col' :: (s :-> a) -> Col' s a -- | Helper for making a Col' col' :: a -> Col' s a instance GHC.Float.Floating a => GHC.Float.Floating (s Frames.Col.:-> a) instance GHC.Real.Fractional a => GHC.Real.Fractional (s Frames.Col.:-> a) instance GHC.Real.RealFrac a => GHC.Real.RealFrac (s Frames.Col.:-> a) instance GHC.Float.RealFloat a => GHC.Float.RealFloat (s Frames.Col.:-> a) instance GHC.Real.Real a => GHC.Real.Real (s Frames.Col.:-> a) instance GHC.Base.Monoid a => GHC.Base.Monoid (s Frames.Col.:-> a) instance GHC.Num.Num a => GHC.Num.Num (s Frames.Col.:-> a) instance GHC.Classes.Ord a => GHC.Classes.Ord (s Frames.Col.:-> a) instance GHC.Classes.Eq a => GHC.Classes.Eq (s Frames.Col.:-> a) instance (GHC.TypeLits.KnownSymbol s, GHC.Show.Show a) => GHC.Show.Show (s Frames.Col.:-> a) instance (GHC.TypeLits.KnownSymbol s, GHC.Show.Show a) => GHC.Show.Show (Frames.Col.Col' s a) module Frames.RecF -- | Two records may be pasted together. rappend :: Rec k f as -> Rec k f bs -> Rec k f ((++) k as bs) -- | A record may be traversed with respect to its interpretation functor. -- This can be used to yank (some or all) effects from the fields of the -- record to the outside of the record. rtraverse :: Applicative h => (forall (x :: u). f x -> h (g x)) -> Rec u f rs -> h (Rec u g rs) -- | Delete a field from a record rdel :: CanDelete r rs => proxy r -> Rec f rs -> Rec f (RDelete r rs) -- | A constraint that a field can be deleted from a record. type CanDelete r rs = (RElem r rs (RIndex r rs), RDelete r rs ⊆ rs) -- | Add a column to the head of a row. frameCons :: Functor f => f a -> Rec f rs -> Rec f ((s :-> a) : rs) -- | Add a pure column to the head of a row. frameConsA :: Applicative f => a -> Rec f rs -> Rec f ((s :-> a) : rs) -- | Add a column to the tail of a row. Note that the supplied value should -- be a Col to work with the Frames tooling. frameSnoc :: Rec f rs -> f r -> Rec f (rs ++ '[r]) -- | Enforce a constraint on the payload type of each column. type AllCols c ts = AllConstrained c (UnColumn ts) -- | Strip the column information from each element of a list of types. -- | Remove the column name phantom types from a record, leaving you with -- an unadorned Vinyl Rec. class AsVinyl ts toVinyl :: (AsVinyl ts, Functor f) => Rec f ts -> Rec f (UnColumn ts) fromVinyl :: (AsVinyl ts, Functor f) => Rec f (UnColumn ts) -> Rec f ts -- | Map a function across a homogeneous, monomorphic Rec. mapMono :: (AllAre a (UnColumn ts), Functor f, AsVinyl ts) => (a -> a) -> Rec f ts -> Rec f ts -- | Map a typeclass method across a Rec each of whose fields has an -- instance of the typeclass. mapMethod :: forall f c ts. (Functor f, AllConstrained c (UnColumn ts), AsVinyl ts) => Proxy c -> (forall a. c a => a -> a) -> Rec f ts -> Rec f ts -- | The ability to pretty print a Rec's fields. class Functor f => ShowRec f rs -- | Pretty printing of Rec values. showRec :: ShowRec f rs => Rec f rs -> String -- | A type function to convert a Record to a Rec. -- ColFun f (Rec rs) = Rec f rs. class ColumnHeaders (cs :: [*]) -- | Return the column names for a record. columnHeaders :: ColumnHeaders cs => proxy (Rec f cs) -> [String] -- | Return the column names for a record. columnHeaders :: ColumnHeaders cs => proxy (Rec f cs) -> [String] -- | Build a record whose elements are derived solely from a constraint -- satisfied by each. reifyDict :: forall c f proxy ts. (AllConstrained c ts, RecApplicative ts) => proxy c -> (forall a. c a => f a) -> Rec f ts instance Frames.RecF.ColumnHeaders '[] instance (Frames.RecF.ColumnHeaders cs, GHC.TypeLits.KnownSymbol s) => Frames.RecF.ColumnHeaders (s Frames.Col.:-> c : cs) instance Frames.RecF.AsVinyl '[] instance Frames.RecF.AsVinyl ts => Frames.RecF.AsVinyl (s Frames.Col.:-> t : ts) instance GHC.Base.Functor f => Frames.RecF.ShowRec f '[] instance (GHC.TypeLits.KnownSymbol s, GHC.Show.Show (f (Frames.Col.Col' s a)), Frames.RecF.ShowRec f rs) => Frames.RecF.ShowRec f (s Frames.Col.:-> a : rs) module Frames.ColumnUniverse -- | Generalize algebraic sum types. data CoRec k (a :: k -> *) (b :: [k]) :: forall k. (k -> *) -> [k] -> * -- | A universe of common column variants. These are the default column -- types that Frames can infer. See the Tutorial for an -- example of extending the default types with your own. type Columns = ColumnUniverse CommonColumns -- | Define a set of variants that captures all possible column types. type ColumnUniverse = CoRec ColInfo -- | Common column types type CommonColumns = '[Bool, Int, Double, Text] parsedTypeRep :: ColInfo a -> Parsed TypeRep instance (Data.Text.Internal.Text Data.Vinyl.Lens.∈ ts) => GHC.Base.Monoid (Data.Vinyl.CoRec.CoRec Frames.ColumnUniverse.ColInfo ts) instance (Data.Vinyl.TypeLevel.AllConstrained Frames.ColumnTypeable.Parseable ts, Data.Vinyl.TypeLevel.AllConstrained Data.Typeable.Internal.Typeable ts, Data.Vinyl.CoRec.FoldRec ts ts, Data.Vinyl.Core.RecApplicative ts, Data.Text.Internal.Text Data.Vinyl.Lens.∈ ts) => Frames.ColumnTypeable.ColumnTypeable (Data.Vinyl.CoRec.CoRec Frames.ColumnUniverse.ColInfo ts) module Frames.Rec -- | A record with unadorned values. This is Vinyl's Rec -- Identity. We give this type a name as it is used pervasively -- for records in Frames. type Record = Rec Identity -- | A cons function for building Record values. (&:) :: a -> Record rs -> Record ((s :-> a) : rs) infixr 5 &: -- | Separate the first element of a Record from the rest of the -- row. recUncons :: Record ((s :-> a) : rs) -> (a, Record rs) -- | Undistribute Maybe from a Rec Maybe. This is just -- a specific usage of rtraverse, but it is quite common. recMaybe :: Rec Maybe cs -> Maybe (Record cs) -- | Show each field of a Record without its column name. showFields :: (RecAll Identity (UnColumn ts) Show, AsVinyl ts) => Record ts -> [String] -- | Functions useful for interactively exploring and experimenting with a -- data set. module Frames.Exploration -- | preview src n f prints out the first n results of -- piping src through f. pipePreview :: (MonadIO m, Show b) => Producer a m () -> Int -> Pipe a b m () -> m () -- | select (Proxy::Proxy [A,B,C]) extracts columns A, -- B, and C, from a larger record. Note, this is just a -- way of pinning down the type of a usage of rcast. select :: (fs ⊆ rs) => proxy fs -> Record rs -> Record fs -- | lenses (Proxy::Proxy [A,B,C]) provides a lens onto columns -- A, B, and C. This is just a way of pinning -- down the type of rsubset. lenses :: (fs ⊆ rs, Functor f) => proxy fs -> (Record fs -> f (Record fs)) -> Record rs -> f (Record rs) recToList :: (AsVinyl rs, AllAre a (UnColumn rs)) => Record rs -> [a] -- | A proxy value quasiquoter; a way of passing types as values. -- [pr|T|] will splice an expression Proxy::Proxy T, -- while [pr|A,B,C|] will splice in a value of Proxy :: -- Proxy [A,B,C]. If we have a record type with Name and -- Age among other fields, we can write select -- [pr|Name,Age|]@ for a function that extracts those fields from a -- larger record. pr :: QuasiQuoter -- | Like pr, but takes a single type, which is used to produce a -- Proxy for a single-element list containing only that type. This -- is useful for passing a single type to a function that wants a list of -- types. pr1 :: QuasiQuoter -- | A Frame is a finite Int-indexed collection of rows. module Frames.Frame -- | A Frame is a finite collection of rows indexed by Int. data Frame r Frame :: !Int -> (Int -> r) -> Frame r [frameLength] :: Frame r -> !Int [frameRow] :: Frame r -> Int -> r -- | A Frame whose rows are Record values. type FrameRec rs = Frame (Record rs) -- | Build a Frame from any Foldable. This simply uses a -- boxed Vector to hold each row. If you have a collection of -- Records, consider using toFrame. boxedFrame :: Foldable f => f r -> Frame r -- | The Monoid instance for Frame provides a mechanism for -- vertical concatenation of Frames. That is, f1 <> -- f2 will return a new Frame with the rows of f1 -- followed by the rows of f2. -- | Horizontal Frame concatenation. That is, zipFrames f1 -- f2 will return a Frame with as many rows as the smaller of -- f1 and f2 whose rows are the result of appending the -- columns of f2 to those of f1. zipFrames :: FrameRec rs -> FrameRec rs' -> FrameRec (rs ++ rs') instance GHC.Base.Functor Frames.Frame.Frame instance GHC.Classes.Eq r => GHC.Classes.Eq (Frames.Frame.Frame r) instance GHC.Base.Monoid (Frames.Frame.Frame r) instance Data.Foldable.Foldable Frames.Frame.Frame instance GHC.Base.Applicative Frames.Frame.Frame instance GHC.Base.Monad Frames.Frame.Frame -- | Efficient in-memory (in-core) storage of tabular data. module Frames.InCore -- | The most efficient vector type for each column data type. -- | The mutable version of VectorFor a particular type. type VectorMFor a = Mutable (VectorFor a) -- | Since we stream into the in-memory representation, we use an -- exponential growth strategy to resize arrays as more data is read in. -- This is the initial capacity of each column. initialCapacity :: Int -- | Mutable vector types for each column in a row. -- | Immutable vector types for each column in a row. -- | Tooling to allocate, grow, write to, freeze, and index into records of -- vectors. class RecVec rs allocRec :: (RecVec rs, PrimMonad m) => proxy rs -> m (Record (VectorMs m rs)) freezeRec :: (RecVec rs, PrimMonad m) => proxy rs -> Int -> Record (VectorMs m rs) -> m (Record (Vectors rs)) growRec :: (RecVec rs, PrimMonad m) => proxy rs -> Record (VectorMs m rs) -> m (Record (VectorMs m rs)) writeRec :: (RecVec rs, PrimMonad m) => proxy rs -> Int -> Record (VectorMs m rs) -> Record rs -> m () indexRec :: RecVec rs => proxy rs -> Int -> Record (Vectors rs) -> Record rs produceRec :: RecVec rs => proxy rs -> Record (Vectors rs) -> Rec ((->) Int) rs -- | Stream a finite sequence of rows into an efficient in-memory -- representation for further manipulation. Each column of the input -- table will be stored optimally based on its type, making use of the -- resulting generators a matter of indexing into a densely packed -- representation. Returns the number of rows and a record of column -- indexing functions. See toAoS to convert the result to a -- Frame which provides an easier-to-use function that indexes -- into the table in a row-major fashion. inCoreSoA :: forall m rs. (PrimMonad m, RecVec rs) => Producer (Record rs) m () -> m (Int, Rec ((->) Int) rs) -- | Stream a finite sequence of rows into an efficient in-memory -- representation for further manipulation. Each column of the input -- table will be stored optimally based on its type, making use of the -- resulting generators a matter of indexing into a densely packed -- representation. Returns a Frame that provides a function to -- index into the table. inCoreAoS :: (PrimMonad m, RecVec rs) => Producer (Record rs) m () -> m (FrameRec rs) -- | Like inCoreAoS, but applies the provided function to the record -- of columns before building the Frame. inCoreAoS' :: (PrimMonad m, RecVec rs) => (Rec ((->) Int) rs -> Rec ((->) Int) ss) -> Producer (Record rs) m () -> m (FrameRec ss) -- | Convert a structure-of-arrays to an array-of-structures. This can -- simplify usage of an in-memory representation. toAoS :: Int -> Rec ((->) Int) rs -> FrameRec rs -- | Stream a finite sequence of rows into an efficient in-memory -- representation for further manipulation. Each column of the input -- table will be stored optimally based on its type, making use of the -- resulting generator a matter of indexing into a densely packed -- representation. inCore :: forall m n rs. (PrimMonad m, RecVec rs, Monad n) => Producer (Record rs) m () -> m (Producer (Record rs) n ()) -- | Build a Frame from a collection of Records using -- efficient column-based storage. toFrame :: (Foldable f, RecVec rs) => f (Record rs) -> Frame (Record rs) -- | Keep only those rows of a FrameRec that satisfy a predicate. filterFrame :: RecVec rs => (Record rs -> Bool) -> FrameRec rs -> FrameRec rs instance Frames.InCore.RecVec '[] instance (Data.Vector.Generic.Mutable.Base.MVector (Frames.InCore.VectorMFor a) a, Data.Vector.Generic.Base.Vector (Frames.InCore.VectorFor a) a, Frames.InCore.RecVec rs) => Frames.InCore.RecVec (s Frames.Col.:-> a : rs) module Frames.Melt type ElemOf ts r = RElem r ts (RIndex r ts) class RowToColumn ts rs rowToColumnAux :: RowToColumn ts rs => Proxy ts -> Rec f rs -> [CoRec f ts] -- | Transform a record into a list of its fields, retaining proof that -- each field is part of the whole. rowToColumn :: RowToColumn ts ts => Rec f ts -> [CoRec f ts] meltAux :: forall vs ss ts. (vs ⊆ ts, ss ⊆ ts, Disjoint ss ts ~ True, ts ≅ (vs ++ ss), ColumnHeaders vs, RowToColumn vs vs) => Record ts -> [Record (("value" :-> CoRec Identity vs) : ss)] -- | This is melt, but the variables are at the front of the record, -- which reads a bit odd. meltRow' :: forall proxy vs ts ss. (vs ⊆ ts, ss ⊆ ts, vs ~ RDeleteAll ss ts, Disjoint ss ts ~ True, ts ≅ (vs ++ ss), ColumnHeaders vs, RowToColumn vs vs) => proxy ss -> Record ts -> [Record (("value" :-> CoRec Identity vs) : ss)] -- | Turn a cons into a snoc after the fact. retroSnoc :: forall t ts. Record (t : ts) -> Record (ts ++ '[t]) -- | Like melt in the reshape2 package for the R -- language. It stacks multiple columns into a single column over -- multiple rows. Takes a specification of the id columns that remain -- unchanged. The remaining columns will be stacked. -- -- Suppose we have a record, r :: Record [Name,Age,Weight]. If -- we apply melt [pr1|Name|] r, we get two values with type -- Record [Name, "value" :-> CoRec Identity [Age,Weight]]. -- The first will contain Age in the value column, and -- the second will contain Weight in the value column. meltRow :: (vs ⊆ ts, ss ⊆ ts, vs ~ RDeleteAll ss ts, Disjoint ss ts ~ True, ts ≅ (vs ++ ss), ColumnHeaders vs, RowToColumn vs vs) => proxy ss -> Record ts -> [Record (ss ++ '["value" :-> CoRec Identity vs])] class HasLength (ts :: [k]) hasLength :: HasLength ts => proxy ts -> Int -- | Applies meltRow to each row of a FrameRec. melt :: forall vs ts ss proxy. (vs ⊆ ts, ss ⊆ ts, vs ~ RDeleteAll ss ts, HasLength vs, Disjoint ss ts ~ True, ts ≅ (vs ++ ss), ColumnHeaders vs, RowToColumn vs vs) => proxy ss -> FrameRec ts -> FrameRec (ss ++ '["value" :-> CoRec Identity vs]) instance forall k (ts :: [k]). Frames.Melt.RowToColumn ts '[] instance forall a (r :: a) (ts :: [a]) (rs :: [a]). (r Data.Vinyl.Lens.∈ ts, Frames.Melt.RowToColumn ts rs) => Frames.Melt.RowToColumn ts (r : rs) instance Frames.Melt.HasLength '[] instance forall k (t :: k) (ts :: [k]). Frames.Melt.HasLength ts => Frames.Melt.HasLength (t : ts) -- | Lens utilities for working with Records. module Frames.RecLens rlens' :: (i ~ RIndex r rs, RElem r rs i, Functor f) => sing r -> (g r -> f (g r)) -> Rec g rs -> f (Rec g rs) -- | Getter for a Rec field rget' :: Functor g => (forall f. Functor f => (g (s :-> a) -> f (g (s :-> a))) -> Rec g rs -> f (Rec g rs)) -> Rec g rs -> g a -- | Setter for a Rec field. rput' :: Functor g => (forall f. Functor f => (g (s :-> a) -> f (g (s :-> a))) -> Rec g rs -> f (Rec g rs)) -> g a -> Rec g rs -> Rec g rs -- | Create a lens for accessing a field of a Record. rlens :: (Functor f, RElem (s :-> a) rs (RIndex (s :-> a) rs)) => proxy (s :-> a) -> (a -> f a) -> Record rs -> f (Record rs) -- | Getter for a Record field. rget :: (forall f. Functor f => (a -> f a) -> Record rs -> f (Record rs)) -> Record rs -> a -- | Setter for a Record field. rput :: (forall f. Functor f => (a -> f a) -> Record rs -> f (Record rs)) -> a -> Record rs -> Record rs -- | Infer row types from comma-separated values (CSV) data and read that -- data from files. Template Haskell is used to generate the necessary -- types so that you can write type safe programs referring to those -- types. module Frames.CSV type Separator = Text type QuoteChar = Char data QuotingMode -- | No quoting enabled. The separator may not appear in values NoQuoting :: QuotingMode -- | Quoted values with the given quoting character. Quotes are escaped by -- doubling them. Mostly RFC4180 compliant, except doesn't support -- newlines in values RFC4180Quoting :: QuoteChar -> QuotingMode data ParserOptions ParserOptions :: Maybe [Text] -> Separator -> QuotingMode -> ParserOptions [headerOverride] :: ParserOptions -> Maybe [Text] [columnSeparator] :: ParserOptions -> Separator [quotingMode] :: ParserOptions -> QuotingMode -- | Default ParseOptions get column names from a header line, and -- use commas to separate columns. defaultParser :: ParserOptions -- | Default separator string. defaultSep :: Separator -- | Helper to split a Text on commas and strip leading and trailing -- whitespace from each resulting chunk. tokenizeRow :: ParserOptions -> Text -> [Text] -- | Post processing applied to a list of tokens split by the separator -- which should have quoted sections reassembeld reassembleRFC4180QuotedParts :: Separator -> QuoteChar -> [Text] -> [Text] -- | Infer column types from a prefix (up to 1000 lines) of a CSV file. prefixInference :: (ColumnTypeable a, Monoid a) => ParserOptions -> Handle -> IO [a] -- | Extract column names and inferred types from a CSV file. readColHeaders :: (ColumnTypeable a, Monoid a) => ParserOptions -> FilePath -> IO [(Text, a)] -- | Parsing each component of a RecF from a list of text chunks, -- one chunk per record component. class ReadRec (rs :: [*]) readRec :: ReadRec rs => [Text] -> Rec Maybe rs -- | Read a RecF from one line of CSV. readRow :: ReadRec rs => ParserOptions -> Text -> Rec Maybe rs -- | Produce rows where any given entry can fail to parse. readTableMaybeOpt :: (MonadIO m, ReadRec rs) => ParserOptions -> FilePath -> Producer (Rec Maybe rs) m () -- | Produce rows where any given entry can fail to parse. readTableMaybe :: (MonadIO m, ReadRec rs) => FilePath -> Producer (Rec Maybe rs) m () -- | Returns a MonadPlus producer of rows for which each column was -- successfully parsed. This is typically slower than -- readTableOpt. readTableOpt' :: forall m rs. (MonadPlus m, MonadIO m, ReadRec rs) => ParserOptions -> FilePath -> m (Record rs) -- | Returns a MonadPlus producer of rows for which each column was -- successfully parsed. This is typically slower than readTable. readTable' :: forall m rs. (MonadPlus m, MonadIO m, ReadRec rs) => FilePath -> m (Record rs) -- | Returns a producer of rows for which each column was successfully -- parsed. readTableOpt :: forall m rs. (MonadIO m, ReadRec rs) => ParserOptions -> FilePath -> Producer (Record rs) m () -- | Returns a producer of rows for which each column was successfully -- parsed. readTable :: forall m rs. (MonadIO m, ReadRec rs) => FilePath -> Producer (Record rs) m () -- | Generate a column type. recDec :: [(Text, Q Type)] -> Q Type -- | Massage a column name from a CSV file into a valid Haskell type -- identifier. sanitizeTypeName :: Text -> Text -- | Declare a type synonym for a column. mkColTDec :: TypeQ -> Name -> DecQ -- | Declare a singleton value of the given column type and lenses for -- working with that column. mkColPDec :: Name -> TypeQ -> Text -> DecsQ lowerHead :: Text -> Maybe Text -- | For each column, we declare a type synonym for its type, and a Proxy -- value of that type. colDec :: ColumnTypeable a => Text -> Text -> a -> DecsQ -- | Splice for manually declaring a column of a given type. For example, -- declareColumn "x2" ''Double will declare a type synonym -- type X2 = "x2" :-> Double and a lens x2. declareColumn :: Text -> Name -> DecsQ -- | Control how row and named column types are generated. data RowGen a RowGen :: [String] -> String -> Separator -> String -> Proxy a -> RowGen a -- | Use these column names. If empty, expect a header row in the data file -- to provide column names. [columnNames] :: RowGen a -> [String] -- | A common prefix to use for every generated declaration. [tablePrefix] :: RowGen a -> String -- | The string that separates the columns on a row. [separator] :: RowGen a -> Separator -- | The row type that enumerates all columns. [rowTypeName] :: RowGen a -> String -- | A type that identifies all the types that can be used to classify a -- column. This is essentially a type-level list of types. See -- colQ. [columnUniverse] :: RowGen a -> Proxy a -- | Shorthand for a Proxy value of ColumnUniverse applied to -- the given type list. colQ :: Name -> Q Exp -- | A default RowGen. This instructs the type inference engine to -- get column names from the data file, use the default column separator -- (a comma), infer column types from the default Columns set of -- types, and produce a row type with name Row. rowGen :: RowGen Columns -- | Generate a type for each row of a table. This will be something like -- Record ["x" :-> a, "y" :-> b, "z" :-> c]. tableType :: String -> FilePath -> DecsQ -- | Like tableType, but additionally generates a type synonym for -- each column, and a proxy value of that type. If the CSV file has -- column names "foo", "bar", and "baz", then this will declare type -- Foo = "foo" :-> Int, for example, foo = rlens (Proxy :: -- Proxy Foo), and foo' = rlens' (Proxy :: Proxy Foo). tableTypes :: String -> FilePath -> DecsQ -- | Generate a type for a row of a table. This will be something like -- Record ["x" :-> a, "y" :-> b, "z" :-> c]. Column -- type synonyms are not generated (see tableTypes'). tableType' :: forall a. (ColumnTypeable a, Monoid a) => RowGen a -> FilePath -> DecsQ -- | Generate a type for a row of a table all of whose columns remain -- unparsed Text values. tableTypesText' :: forall a. (ColumnTypeable a, Monoid a) => RowGen a -> FilePath -> DecsQ -- | Like tableType', but additionally generates a type synonym for -- each column, and a proxy value of that type. If the CSV file has -- column names "foo", "bar", and "baz", then this will declare type -- Foo = "foo" :-> Int, for example, foo = rlens (Proxy :: -- Proxy Foo), and foo' = rlens' (Proxy :: Proxy Foo). tableTypes' :: forall a. (ColumnTypeable a, Monoid a) => RowGen a -> FilePath -> DecsQ -- | yield a header row with column names followed by a line of text -- for each Record with each field separated by a comma. produceCSV :: forall f ts m. (ColumnHeaders ts, AsVinyl ts, Foldable f, Monad m, RecAll Identity (UnColumn ts) Show) => f (Record ts) -> Producer String m () -- | Write a header row with column names followed by a line of text for -- each Record to the given file. writeCSV :: (ColumnHeaders ts, AsVinyl ts, Foldable f, RecAll Identity (UnColumn ts) Show) => FilePath -> f (Record ts) -> IO () instance GHC.Show.Show Frames.CSV.ParserOptions instance GHC.Classes.Eq Frames.CSV.ParserOptions instance GHC.Show.Show Frames.CSV.QuotingMode instance GHC.Classes.Eq Frames.CSV.QuotingMode instance Language.Haskell.TH.Syntax.Lift Frames.CSV.QuotingMode instance Language.Haskell.TH.Syntax.Lift Frames.CSV.ParserOptions instance Frames.CSV.ReadRec '[] instance (Frames.ColumnTypeable.Parseable t, Frames.CSV.ReadRec ts) => Frames.CSV.ReadRec (s Frames.Col.:-> t : ts) -- | User-friendly, type safe, runtime efficient tooling for working with -- tabular data deserialized from comma-separated values (CSV) files. The -- type of each row of data is inferred from data, which can then be -- streamed from disk, or worked with in memory. module Frames -- | A space efficient, packed, unboxed Unicode text type. data Text :: *