sv-0.1: Encode and decode separated values (CSV, PSV, ...)

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

Data.Sv.Syntax.Field

Description

 

Synopsis

Documentation

data Field s Source #

A Field is a single cell from a CSV document.

Its value is either Quoted, which indicates the type of quote surrounding the value, or it is Unquoted, containing only the value.

Constructors

Unquoted s 
Quoted Quote (Unescaped s) 

Instances

Functor Field Source # 

Methods

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

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

Foldable Field Source # 

Methods

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

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

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

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

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

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

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

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

toList :: Field a -> [a] #

null :: Field a -> Bool #

length :: Field a -> Int #

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

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

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

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

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

Traversable Field Source # 

Methods

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

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

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

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

Eq s => Eq (Field s) Source # 

Methods

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

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

Ord s => Ord (Field s) Source # 

Methods

compare :: Field s -> Field s -> Ordering #

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

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

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

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

max :: Field s -> Field s -> Field s #

min :: Field s -> Field s -> Field s #

Show s => Show (Field s) Source # 

Methods

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

show :: Field s -> String #

showList :: [Field s] -> ShowS #

Generic (Field s) Source # 

Associated Types

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

Methods

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

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

NFData s => NFData (Field s) Source # 

Methods

rnf :: Field s -> () #

AsField (Field a) a Source # 
MonadReader (Vector (SpacedField s)) (DecodeState s) # 
HasFields (Field s) (Field t) s t Source # 

Methods

fields :: Traversal (Field s) (Field t) (Field s) (Field t) Source #

type Rep (Field s) Source # 

type SpacedField a = Spaced (Field a) Source #

Fields are often surrounded by spaces

data Spaced a Source #

Spaced is a value with zero or many horizontal spaces around it on both sides.

Constructors

Spaced Spaces Spaces a 

Instances

Functor Spaced Source # 

Methods

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

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

Applicative Spaced Source #

Appends the right parameter on the inside of the left parameter

Spaced "   " () " " *> Spaced "\t\t\t" () "\t \t" == Spaced "   \t\t\t" () "\t \t "

Methods

pure :: a -> Spaced a #

(<*>) :: Spaced (a -> b) -> Spaced a -> Spaced b #

liftA2 :: (a -> b -> c) -> Spaced a -> Spaced b -> Spaced c #

(*>) :: Spaced a -> Spaced b -> Spaced b #

(<*) :: Spaced a -> Spaced b -> Spaced a #

Foldable Spaced Source # 

Methods

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

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

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

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

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

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

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

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

toList :: Spaced a -> [a] #

null :: Spaced a -> Bool #

length :: Spaced a -> Int #

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

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

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

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

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

Traversable Spaced Source # 

Methods

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

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

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

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

Eq a => Eq (Spaced a) Source # 

Methods

(==) :: Spaced a -> Spaced a -> Bool #

(/=) :: Spaced a -> Spaced a -> Bool #

Ord a => Ord (Spaced a) Source # 

Methods

compare :: Spaced a -> Spaced a -> Ordering #

(<) :: Spaced a -> Spaced a -> Bool #

(<=) :: Spaced a -> Spaced a -> Bool #

(>) :: Spaced a -> Spaced a -> Bool #

(>=) :: Spaced a -> Spaced a -> Bool #

max :: Spaced a -> Spaced a -> Spaced a #

min :: Spaced a -> Spaced a -> Spaced a #

Show a => Show (Spaced a) Source # 

Methods

showsPrec :: Int -> Spaced a -> ShowS #

show :: Spaced a -> String #

showList :: [Spaced a] -> ShowS #

Generic (Spaced a) Source # 

Associated Types

type Rep (Spaced a) :: * -> * #

Methods

from :: Spaced a -> Rep (Spaced a) x #

to :: Rep (Spaced a) x -> Spaced a #

NFData a => NFData (Spaced a) Source # 

Methods

rnf :: Spaced a -> () #

MonadReader (Vector (SpacedField s)) (DecodeState s) # 
HasSpaced (Spaced a) (Spaced b) a b Source # 
type Rep (Spaced a) Source # 

class HasFields c d s t | c -> s, d -> t, c t -> d, d s -> c where Source #

Classy Traversal' for things containing Fields

Minimal complete definition

fields

Methods

fields :: Traversal c d (Field s) (Field t) Source #

Instances

HasFields (Field s) (Field t) s t Source # 

Methods

fields :: Traversal (Field s) (Field t) (Field s) (Field t) Source #

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

Methods

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

HasFields (Header a) (Header b) a b Source # 

Methods

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

class HasFields s s a a => AsField s a | s -> a where Source #

Classy prisms for Field

Minimal complete definition

_Field

unescapedField :: Quote -> s -> Field s Source #

Build a quoted field with a normal string

foldField :: (s -> b) -> (Quote -> Unescaped s -> b) -> Field s -> b Source #

The catamorphism for Field'

fieldContents :: Lens (Field s) (Field t) s t Source #

Lens into the contents of a Field, regardless of whether it's quoted or unquoted