svfactor-0.1: Syntax-preserving CSV manipulation

Copyright(C) CSIRO 2017-2018
LicenseBSD3
MaintainerGeorge Wilson <george.wilson@data61.csiro.au>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Svfactor.Syntax.Record

Description

This module contains datatypes for Records. A record is a "line" or "row" of a CSV document

Synopsis

Documentation

newtype Record s Source #

A Record is a non-empty collection of Fields, implicitly separated by a separator (often a comma).

Constructors

Record 
Instances
Functor Record Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Methods

fmap :: (a -> b) -> Record a -> Record b #

(<$) :: a -> Record b -> Record a #

Foldable Record Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Methods

fold :: Monoid m => Record m -> m #

foldMap :: Monoid m => (a -> m) -> Record a -> m #

foldr :: (a -> b -> b) -> b -> Record a -> b #

foldr' :: (a -> b -> b) -> b -> Record a -> b #

foldl :: (b -> a -> b) -> b -> Record a -> b #

foldl' :: (b -> a -> b) -> b -> Record a -> b #

foldr1 :: (a -> a -> a) -> Record a -> a #

foldl1 :: (a -> a -> a) -> Record a -> a #

toList :: Record a -> [a] #

null :: Record a -> Bool #

length :: Record a -> Int #

elem :: Eq a => a -> Record a -> Bool #

maximum :: Ord a => Record a -> a #

minimum :: Ord a => Record a -> a #

sum :: Num a => Record a -> a #

product :: Num a => Record a -> a #

Traversable Record Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Methods

traverse :: Applicative f => (a -> f b) -> Record a -> f (Record b) #

sequenceA :: Applicative f => Record (f a) -> f (Record a) #

mapM :: Monad m => (a -> m b) -> Record a -> m (Record b) #

sequence :: Monad m => Record (m a) -> m (Record a) #

Eq s => Eq (Record s) Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Methods

(==) :: Record s -> Record s -> Bool #

(/=) :: Record s -> Record s -> Bool #

Ord s => Ord (Record s) Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Methods

compare :: Record s -> Record s -> Ordering #

(<) :: Record s -> Record s -> Bool #

(<=) :: Record s -> Record s -> Bool #

(>) :: Record s -> Record s -> Bool #

(>=) :: Record s -> Record s -> Bool #

max :: Record s -> Record s -> Record s #

min :: Record s -> Record s -> Record s #

Show s => Show (Record s) Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Methods

showsPrec :: Int -> Record s -> ShowS #

show :: Record s -> String #

showList :: [Record s] -> ShowS #

Generic (Record s) Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Associated Types

type Rep (Record s) :: * -> * #

Methods

from :: Record s -> Rep (Record s) x #

to :: Rep (Record s) x -> Record s #

Semigroup (Record s) Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Methods

(<>) :: Record s -> Record s -> Record s #

sconcat :: NonEmpty (Record s) -> Record s #

stimes :: Integral b => b -> Record s -> Record s #

NFData s => NFData (Record s) Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Methods

rnf :: Record s -> () #

HasFields (Record a) (Record b) a b Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Methods

fields :: Traversal (Record a) (Record b) (Field a) (Field b) Source #

HasRecord (Record a) (Record b) a b Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

type Rep (Record s) Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

type Rep (Record s) = D1 (MetaData "Record" "Data.Svfactor.Syntax.Record" "svfactor-0.1-GDLTyJD8FfREVKdyivwTvx" True) (C1 (MetaCons "Record" PrefixI True) (S1 (MetaSel (Just "_fields") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (NonEmptyVector (Spaced (Field s))))))

class HasRecord s t a b | s -> a, t -> b where Source #

Classy lenses for Record

Minimal complete definition

record

Instances
HasRecord (Record a) (Record b) a b Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

HasRecord (Header a) (Header b) a b Source # 
Instance details

Defined in Data.Svfactor.Syntax.Sv

emptyRecord :: Monoid s => Record s Source #

Build an empty record.

According to RFC 4180, a record must have at least one field. But a field can be the empty string. So this is the closest we can get to an empty record.

Note that this does not make Record a Monoid. It is not a lawful unit for the Semigroup operation.

singleField :: Field s -> Record s Source #

Build a Record with just one Field

recordNel :: NonEmpty (SpacedField s) -> Record s Source #

Build a Record given a NonEmpty list of its fields

data Records s Source #

A collection of records, separated by newlines.

Constructors

EmptyRecords 
Records (Record s) (Vector (Newline, Record s)) 
Instances
Functor Records Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Methods

fmap :: (a -> b) -> Records a -> Records b #

(<$) :: a -> Records b -> Records a #

Foldable Records Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Methods

fold :: Monoid m => Records m -> m #

foldMap :: Monoid m => (a -> m) -> Records a -> m #

foldr :: (a -> b -> b) -> b -> Records a -> b #

foldr' :: (a -> b -> b) -> b -> Records a -> b #

foldl :: (b -> a -> b) -> b -> Records a -> b #

foldl' :: (b -> a -> b) -> b -> Records a -> b #

foldr1 :: (a -> a -> a) -> Records a -> a #

foldl1 :: (a -> a -> a) -> Records a -> a #

toList :: Records a -> [a] #

null :: Records a -> Bool #

length :: Records a -> Int #

elem :: Eq a => a -> Records a -> Bool #

maximum :: Ord a => Records a -> a #

minimum :: Ord a => Records a -> a #

sum :: Num a => Records a -> a #

product :: Num a => Records a -> a #

Traversable Records Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Methods

traverse :: Applicative f => (a -> f b) -> Records a -> f (Records b) #

sequenceA :: Applicative f => Records (f a) -> f (Records a) #

mapM :: Monad m => (a -> m b) -> Records a -> m (Records b) #

sequence :: Monad m => Records (m a) -> m (Records a) #

Eq s => Eq (Records s) Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Methods

(==) :: Records s -> Records s -> Bool #

(/=) :: Records s -> Records s -> Bool #

Ord s => Ord (Records s) Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Methods

compare :: Records s -> Records s -> Ordering #

(<) :: Records s -> Records s -> Bool #

(<=) :: Records s -> Records s -> Bool #

(>) :: Records s -> Records s -> Bool #

(>=) :: Records s -> Records s -> Bool #

max :: Records s -> Records s -> Records s #

min :: Records s -> Records s -> Records s #

Show s => Show (Records s) Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Methods

showsPrec :: Int -> Records s -> ShowS #

show :: Records s -> String #

showList :: [Records s] -> ShowS #

Generic (Records s) Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Associated Types

type Rep (Records s) :: * -> * #

Methods

from :: Records s -> Rep (Records s) x #

to :: Rep (Records s) x -> Records s #

NFData s => NFData (Records s) Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

Methods

rnf :: Records s -> () #

HasRecords (Records s) s Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

type Rep (Records s) Source # 
Instance details

Defined in Data.Svfactor.Syntax.Record

type Rep (Records s) = D1 (MetaData "Records" "Data.Svfactor.Syntax.Record" "svfactor-0.1-GDLTyJD8FfREVKdyivwTvx" False) (C1 (MetaCons "EmptyRecords" PrefixI False) (U1 :: * -> *) :+: C1 (MetaCons "Records" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Record s)) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Vector (Newline, Record s)))))

_EmptyRecords :: Prism' (Records s) () Source #

Prism for an empty Records

_NonEmptyRecords :: Prism (Records s) (Records t) (Record s, Vector (Newline, Record s)) (Record t, Vector (Newline, Record t)) Source #

Prism for a non-empty Records

mkRecords :: Newline -> NonEmpty (Record s) -> Records s Source #

Convenience constructor for Records.

This puts the same newline between all the records.

singleRecord :: Record s -> Records s Source #

A record collection conaining one record

recordList :: HasRecords c s => c -> [Record s] Source #

Collect the list of Records from anything that HasRecords