dataframe-0.3.3.5: A fast, safe, and intuitive DataFrame library.
Safe HaskellNone
LanguageHaskell2010

DataFrame.Internal.Schema

Synopsis

Documentation

data SchemaType where Source #

A runtime tag for a column’s element type.

Constructors

SType :: forall a. Columnable a => Proxy a -> SchemaType

Constructor carrying a Proxy of the element type.

Instances

Instances details
Show SchemaType Source #

Show the underlying element type using typeRep.

Examples

Expand
>>> :set -XTypeApplications
>>> show (schemaType @Bool)
"Bool"
Instance details

Defined in DataFrame.Internal.Schema

Eq SchemaType Source #

Two SchemaTypes are equal iff their element types are the same.

Examples

Expand
>>> :set -XTypeApplications
>>> schemaType @Int == schemaType @Int
True
>>> schemaType @Int == schemaType @Integer
False
Instance details

Defined in DataFrame.Internal.Schema

schemaType :: Columnable a => SchemaType Source #

Construct a SchemaType for the given a.

Examples

Expand
>>> :set -XTypeApplications
>>> schemaType @T.Text == schemaType @T.Text
True
>>> show (schemaType @Double)
"Double"

newtype Schema Source #

Logical schema of a DataFrame: a mapping from column names to their element types (SchemaType).

Examples

Expand

Constructing and querying a schema:

>>> import qualified Data.Map as M
>>> import qualified Data.Text as T
>>> let s = Schema (M.fromList [("country", schemaType @T.Text), ("amount", schemaType @Double)])
>>> M.lookup "amount" (elements s) == Just (schemaType @Double)
True

Extending a schema:

>>> let s' = Schema (M.insert "discount" (schemaType @Double) (elements s))
>>> M.member "discount" (elements s')
True

Equality is structural over the map contents:

>>> let a = Schema (M.fromList [("x", schemaType @Int), ("y", schemaType @Double)])
>>> let b = Schema (M.fromList [("y", schemaType @Double), ("x", schemaType @Int)])
>>> a == b
True

Constructors

Schema 

Fields

  • elements :: Map Text SchemaType

    Mapping from column name to its SchemaType.

    Invariant: keys are unique column names. A missing key means the column is not present in the schema.

Instances

Instances details
Show Schema Source # 
Instance details

Defined in DataFrame.Internal.Schema

Eq Schema Source # 
Instance details

Defined in DataFrame.Internal.Schema

Methods

(==) :: Schema -> Schema -> Bool #

(/=) :: Schema -> Schema -> Bool #